<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by PYK on Medium]]></title>
        <description><![CDATA[Stories by PYK on Medium]]></description>
        <link>https://medium.com/@pyk_ouo?source=rss-5c3e3a23d657------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Abc2T-3Y1tpUAXIokm7Mgw.jpeg</url>
            <title>Stories by PYK on Medium</title>
            <link>https://medium.com/@pyk_ouo?source=rss-5c3e3a23d657------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:19:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pyk_ouo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SOP (clone a laravel project)]]></title>
            <link>https://medium.com/@pyk_ouo/sop-clone-a-laravel-project-f74e81c002d1?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/f74e81c002d1</guid>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Mon, 26 Mar 2018 05:49:30 GMT</pubDate>
            <atom:updated>2018-03-26T05:49:30.793Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>install apache &amp; mysql</li><li>vi httpd.conf to allow using virtual host</li><li>edit vhost.conf</li><li>set hosts</li><li>clone project</li><li>composer install</li><li>create .env</li><li>php artisan key:generate</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f74e81c002d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel tips]]></title>
            <link>https://medium.com/@pyk_ouo/laravel-tips-88e06d69e8f3?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/88e06d69e8f3</guid>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 08:44:48 GMT</pubDate>
            <atom:updated>2018-02-27T09:11:10.175Z</atom:updated>
            <content:encoded><![CDATA[<h4>（Keep updating）</h4><ul><li><strong>navbar 在 laravel 如何 active</strong></li></ul><p>在寫nav bar時可以利用</p><p>{{ Request::is(&#39;about*&#39;) ? &#39; class=&quot;active&quot;&#39; : null }}</p><p>在/about路徑下時 class=”active” 就會出現</p><pre>/about/123</pre><blockquote><em>參考 Setting Bootstrap navbar active class in Laravel 5</em></blockquote><blockquote><a href="https://stackoverflow.com/questions/29837555/setting-bootstrap-navbar-active-class-in-laravel-5">https://stackoverflow.com/questions/29837555/setting-bootstrap-navbar-active-class-in-laravel-5</a></blockquote><ul><li><strong>forelse 用法</strong></li></ul><p>在使用 foreach 時常需要先判斷是否empty</p><p>但利用 forelse 就可以不用做這件事情了</p><pre>@forelse($friends ad $friend)<br>    &lt;p&gt; say hi to my friend {{$friend[&#39;name&#39;]}} &lt;/p&gt;<br>@empty<br>    &lt;p&gt; You don&#39;t have any friends :( &lt;/p&gt;<br>@endforelse</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88e06d69e8f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel (3) artisan]]></title>
            <link>https://medium.com/@pyk_ouo/laravel-3-artisan-b66d4e908677?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/b66d4e908677</guid>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 08:33:44 GMT</pubDate>
            <atom:updated>2018-02-27T08:33:44.314Z</atom:updated>
            <content:encoded><![CDATA[<pre>php artisan make:model Post</pre><p>using <strong>make </strong>can generate things you want (model/controller/view)</p><h3>Migration</h3><p>We don’t have to create a database first and connect it.</p><pre>php artisan make:model Post — migration</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MfN8msFS3R3ecEFEp7JCGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*ZY27TZjaS5WInmPYhgQZmg.png" /></figure><p>use <strong>Sequel Pro </strong>to operate database with GUI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*yqBeERBDMCzB7QcWk4XVyA.png" /></figure><p>change .env to connect to database</p><pre>DB_DATABASE=blog<br>DB_USERNAME=root<br>DB_PASSWORD=root</pre><p>you can see /config/database.php to find out how Laravel connects database</p><pre>php artisan migrate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VsFZFvaBFESeEWEPIj5Whg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b66d4e908677" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PHP tips — foreach]]></title>
            <link>https://medium.com/@pyk_ouo/php-tips-foreach-3b1cc1a6b4f5?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b1cc1a6b4f5</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[foreach]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 07:53:56 GMT</pubDate>
            <atom:updated>2018-02-26T07:53:56.902Z</atom:updated>
            <content:encoded><![CDATA[<p>一、</p><p>foreach($Users as $User){…}</p><p>即使在{}內寫 $User[‘name’]=&gt;’Andy’; 也不會更改原本 $Users 裡面的值</p><blockquote>PHP foreach change original array values</blockquote><blockquote><a href="https://stackoverflow.com/questions/15024616/php-foreach-change-original-array-values">https://stackoverflow.com/questions/15024616/php-foreach-change-original-array-values</a></blockquote><p>更改成 foreach($Users as &amp;$User){…}</p><p>則是傳入位址因此可以更改到 $Users 的值</p><p>二、</p><p>foreach($Books[‘horror’] as $Books){…}</p><p>這樣會將原本的 $Books 覆寫成 $Books[‘horror’]</p><p>原本的 $Books[‘comics’]、$Books[‘sci-fi’]則會消失</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b1cc1a6b4f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel (2) Controller(route)]]></title>
            <link>https://medium.com/@pyk_ouo/laravel-2-controller-route-869205f3eff1?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/869205f3eff1</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Wed, 06 Dec 2017 05:37:38 GMT</pubDate>
            <atom:updated>2017-12-06T05:38:12.724Z</atom:updated>
            <content:encoded><![CDATA[<p>Although you can write your routes in route.php, we tend to keep our logistics in controller.</p><p>#1 Create PagesController.php</p><p>usually this is how we do in these functions</p><pre>//        process variable data or params<br>//        talk to the model<br>//        receive from model<br>//        compile or process data from the model if needed<br>//        pass that data to the correct view</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*Ai6R4AiidfV9XZy6-lT3BA.png" /></figure><p>#2 Rewrite Route.php point to PagesController.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*DOImrVoJfZWNGOnNkM5hrg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=869205f3eff1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel (1) start/ MVC]]></title>
            <link>https://medium.com/@pyk_ouo/laravel-1-start-mvc-b91369215bd4?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/b91369215bd4</guid>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Wed, 22 Nov 2017 04:05:57 GMT</pubDate>
            <atom:updated>2017-11-22T04:05:57.875Z</atom:updated>
            <content:encoded><![CDATA[<p>using <strong>php artisan serve</strong> to start your server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4In-SHd1MXA9JbukvC7ylA.png" /></figure><p>Then you will see the default page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOMwX1ZREh7U5MqEzlBSxw.png" /></figure><h3><strong>MVC (an architecture </strong>paradigm)</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1IsL6g2ixak%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1IsL6g2ixak&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1IsL6g2ixak%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f5d643debd48ddf90a55668fa0d5df5/href">https://medium.com/media/5f5d643debd48ddf90a55668fa0d5df5/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jc7PRtrQvpjVyuNK_ha9kg.png" /></figure><p><strong>#Model</strong></p><p>connect and react with database</p><p>process the data from database and send to Controller</p><p>connect to Controller only</p><p><strong>#View</strong></p><p>what display to user</p><p>only listen to controller never talks back</p><p><strong>#Controller</strong></p><p>don’t direct talk to the database, only connect to model</p><p>interact with user</p><p>handle all requests</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b91369215bd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Basic File Structure]]></title>
            <link>https://medium.com/@pyk_ouo/laravel-basic-file-structure-197f59366ce1?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/197f59366ce1</guid>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Wed, 22 Nov 2017 03:00:40 GMT</pubDate>
            <atom:updated>2017-11-22T03:00:40.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*YDFs_Zyj1R5mzh1L4kpxfg.png" /></figure><p><strong>#app</strong></p><p>main folder, most logic happens here</p><p>— — under app — —</p><p>#<strong>Console</strong> php artisan cmd</p><p><strong>#Exceptions </strong>process expections</p><p><strong>#Event</strong></p><p><strong>#HTTP</strong> Route/ Controller/ Model</p><p><strong>#User.php</strong> example model(connection to database)</p><p><strong>#database</strong></p><p>— — under database — —</p><p><strong>#migrations</strong> store database structure(easy to replicate)</p><p><strong>#seeds </strong>fake data for testing database</p><p><strong>#pulic </strong>everything is open to everyone</p><p><strong>#resource</strong> we store our asset(javascript/css/view)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=197f59366ce1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Laravel on Mac]]></title>
            <link>https://medium.com/@pyk_ouo/install-laravel-on-mac-3d1d8f2f388a?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d1d8f2f388a</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Tue, 21 Nov 2017 02:19:22 GMT</pubDate>
            <atom:updated>2017-11-21T02:19:22.848Z</atom:updated>
            <content:encoded><![CDATA[<p>Install Laravel on Mac</p><p>#1 Install <strong>homebrew</strong> on your Mac</p><pre>/usr/bin/ruby -e &quot;$( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )&quot;</pre><p>#2 Install <strong>Composer</strong> with homebrew</p><pre>brew tap josegonzalez/homebrew-php  <br>brew install josegonzalez/php/composer</pre><p>#3 Install <strong>Laravel Installer</strong></p><pre>composer global require &quot;laravel/installer&quot;</pre><pre>export PATH=/Users/&lt;user name&gt;/.composer/vendor/bin:$PATH</pre><p>#4 Go to the path you want to<strong> Create Poject</strong></p><pre>laravel new &lt;project name&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d1d8f2f388a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Free Domain Name & DNS with Apache Virtual Host]]></title>
            <link>https://medium.com/@pyk_ouo/free-domain-name-dns-with-apache-virtual-host-c677d8163f27?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/c677d8163f27</guid>
            <category><![CDATA[domain-names]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Mon, 06 Nov 2017 07:18:36 GMT</pubDate>
            <atom:updated>2017-11-06T07:18:36.754Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Using <a href="http://www.dot.tk/en/index.html?lang=en">http://www.dot.tk/en/index.html?lang=en</a> can get several free domain name for 1 months to 12 months</li><li>Enter you domain name in <a href="https://www.cloudflare.com/">https://www.cloudflare.com/</a></li><li>Manage your domain in dot.tk and change the NameServer</li><li>Change DNS in cloudflare</li><li>Set Virtual Host on Apache</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRCcj9p19i5vYIyzjuS1Wg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELdem9q2rdAMA1RglTbHRg.png" /><figcaption>Don’t forget to clear the rest Nameserver</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cyGTDd9ybDKekko9L5mLyg.png" /><figcaption>Point to the IP of your server</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c677d8163f27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PHP PDO basic Database CRUD]]></title>
            <link>https://medium.com/@pyk_ouo/php-pdo-basic-database-crud-93dced2bc3d?source=rss-5c3e3a23d657------2</link>
            <guid isPermaLink="false">https://medium.com/p/93dced2bc3d</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[crud]]></category>
            <dc:creator><![CDATA[PYK]]></dc:creator>
            <pubDate>Wed, 25 Oct 2017 02:15:19 GMT</pubDate>
            <atom:updated>2017-10-25T02:15:19.839Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>I’m using <strong>XAMPP</strong> which means my server is on Apache and I’m using phpmyadmin to manage my database.</blockquote><p>And this is what my database looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*daH3nCj-sd8YwRW1_00BoA.png" /></figure><p>I’ve created 3 tables and added some data in them.</p><p><strong>Connect the Database</strong></p><p><em>Database.php</em></p><pre>class Database{</pre><pre>  private $host = &#39;localhost&#39;;<br>  private $user = &#39;root&#39;;<br>  private $pass = &#39;1234&#39;;<br>  private $dbname = &#39;web&#39;;</pre><pre>  private $dbh; //database hammer<br>  private $error;<br>  private $stmt; //to run the prepared statement</pre><pre>  public function __construct(){<br>    $dsn = &#39;mysql:host=&#39;.$this-&gt;host.&#39;;dbname=&#39;.$this-&gt;dbname;<br>    $options = array(<br>      PDO::ATTR_PERSISTENT =&gt; ture,<br>      PDO::ATTR_ERRMODE    =&gt; PDO::ERRMODE_EXCEPTION<br>    );<br>    <br>    try{<br>      $this-&gt;dbh = new PDO($dsn, $this-&gt;user, $this-&gt;pass, $options);<br>    } catch(PDOEception $e){<br>      $this-&gt;error = $e-&gt;getMessage();<br>    }<br>  }</pre><pre>}</pre><blockquote><strong>PDOEception vs PDOException</strong></blockquote><blockquote>PDOEception : script halts and the default exception message is shown.</blockquote><blockquote>PDOException : won’t show the error of code and the code will continue.</blockquote><p>More information about PDO</p><p><a href="https://phpdelusions.net/pdo">(The only proper) PDO tutorial</a></p><p><em>index.php</em></p><pre>&lt;? php<br>require &#39;classes/Database.php</pre><pre>$database = new Database;</pre><p><strong>CREATE</strong></p><p>create a form</p><pre>&lt;form method=&quot;post&quot; action=&quot;<strong>&lt;?php </strong>$_SERVER[&#39;PHP_SELF&#39;];<strong>?&gt;</strong>&quot;&gt;<br>    &lt;div&gt;&lt;span&gt;UserName:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;userName&quot;&gt;&lt;/div&gt;<br>    &lt;div&gt;&lt;span&gt;Password:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;pass&quot;&gt;&lt;/div&gt;<br>    &lt;div&gt;&lt;span&gt;Pin:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;pin&quot;&gt;&lt;/div&gt;<br>    &lt;div&gt;&lt;span&gt;FirstName:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;firstName&quot;&gt;&lt;/div&gt;<br>    &lt;div&gt;&lt;span&gt;LastName:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;lastName&quot;&gt;&lt;/div&gt;<br>    &lt;button class=&quot;btn1&quot; type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;&gt;Submit&lt;/button&gt;<br>&lt;/form&gt;</pre><blockquote>$_SERVER[‘PHP+SELF’] means submit to the same page</blockquote><p>add php</p><pre>$post = filter_input_array(<em>INPUT_POST</em>, <em>FILTER_SANITIZE_STRING</em>);<br><br><strong>if</strong>(<strong>isset</strong>($post[&#39;submit&#39;])){<br>    <strong>echo </strong>&#39;SUBMITTED&#39;;<br>    $userName = $post[&#39;userName&#39;];<br>    $pass = md5($post[&#39;pass&#39;]); //encrypt<br>    $pin = $post[&#39;pin&#39;];<br>    $firstName = $post[&#39;firstName&#39;];<br>    $lastName = $post[&#39;lastName&#39;];<br>    $database-&gt;query(&#39;INSERT INTO web.users (username,password,pin,first_name,last_name) VALUES (:username, :password, :pin, :first_name, :last_name)&#39;);<br>    $database-&gt;bind(&#39;:username&#39;, $userName);<br>    $database-&gt;bind(&#39;:password&#39;, $pass);<br>    $database-&gt;bind(&#39;:pin&#39;,$pin);<br>    $database-&gt;bind(&#39;:first_name&#39;, $firstName);<br>    $database-&gt;bind(&#39;:last_name&#39;, $lastName);<br>    $database-&gt;execute();<br>    //make sure inserted<br>   <strong>if</strong>($database-&gt;lastInsertID()){<br>        // echo &#39;&lt;p&gt;user added&lt;/p&gt;&#39;;<br>        header(&#39;Location: login.php&#39;);<br>    }<br>}</pre><p><em>database.php</em></p><pre><strong>public function </strong>bind($param, $value, $type = <strong>null</strong>){<br>   <strong>if</strong>(is_null($type)){<br>      <strong>switch</strong>(<strong>true</strong>){<br>         <strong>case </strong>is_int($value):<br>            $type = PDO::<em>PARAM_INT</em>;<br>            <strong>break</strong>;<br>         <strong>case </strong>is_bool($value):<br>            $type = PDO::<em>PARAM_BOOL</em>;<br>            <strong>break</strong>;<br>         <strong>case </strong>is_null($value):<br>            $type = PDO::<em>PARAM_NULL</em>;<br>            <strong>break</strong>;<br>            <strong>default</strong>:<br>            $type = PDO::<em>PARAM_STR</em>;<br>      }<br>   }<br>   $this-&gt;stmt-&gt;bindValue($param, $value, $type);<br>}<br><br><strong>public function </strong>execute(){<br>   <strong>return </strong>$this-&gt;stmt-&gt;execute();<br>}<br><br><strong>public function </strong>resultset(){<br>   $this-&gt;execute();<br>   <strong>return </strong>$this-&gt;stmt-&gt;fetchAll(PDO::<em>FETCH_ASSOC</em>);<br>}<br><strong>public function </strong>lastInsertId(){<br>   $this-&gt;dbh-&gt;lastInsertId();<br>}</pre><p><strong>READ</strong></p><p>create a form</p><pre>&lt;form method=&quot;post&quot; action=&quot;<strong>&lt;?php </strong>$_SERVER[&#39;PHP_SELF&#39;];<strong>?&gt;</strong>&quot;&gt;<br>&lt;div&gt;&lt;span&gt;UserName:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;userName&quot;&gt;&lt;/div&gt;<br>&lt;div&gt;&lt;span&gt;Password:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;pass&quot;&gt;&lt;/div&gt;<br>&lt;div&gt;&lt;span&gt;Pin:&lt;/span&gt;&lt;input type=&quot;text&quot; name=&quot;pin&quot;&gt;&lt;/div&gt;<br>&lt;button class=&quot;btn1&quot; type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;&gt;LOGIN NOW&lt;/button&gt;<br>&lt;/form&gt;</pre><p>add php</p><pre>$post = filter_input_array(<em>INPUT_POST</em>, <em>FILTER_SANITIZE_STRING</em>);<br><br><strong>if</strong>(<strong>isset</strong>($post[&#39;submit&#39;])){<br>    $userName = $post[&#39;userName&#39;];<br>    $pass = md5($post[&#39;pass&#39;]);<br>    $pin = $post[&#39;pin&#39;];<br>    $database-&gt;query(&#39;SELECT * FROM web.users WHERE username = :username AND password = :password AND pin = :pin&#39;);<br>    $database-&gt;bind(&#39;:username&#39;, $userName);<br>    $database-&gt;bind(&#39;:password&#39;, $pass);<br>    $database-&gt;bind(&#39;:pin&#39;,$pin);<br>    $row = $database-&gt;single();<br>    <strong>if</strong>($row){<br>        // echo &#39;logged in&#39;;<br>        // print_r($row) ;<br>        $_SESSION[&#39;is_logged_in&#39;] = <strong>true</strong>;<br>        $_SESSION[&#39;user_data&#39;] = <strong>array</strong>(<br>            &quot;iduser&quot; =&gt; $row[&#39;iduser&#39;],<br>            &quot;username&quot; =&gt; $row[&#39;username&#39;]<br>        );<br>        // print_r($_SESSION[&#39;user_data&#39;]) ;<br>        header(&#39;Location: library.php&#39;);<br>    } <strong>else</strong>{<br>        // echo &#39;incorrect logged in&#39;;<br>    }<br>}</pre><p><em>database.php</em></p><pre><strong>public function </strong>single(){<br>   $this-&gt;execute();<br>   <strong>return </strong>$this-&gt;stmt-&gt;fetch(PDO::<em>FETCH_ASSOC</em>);<br>}<br><strong>public function </strong>multi(){<br>   $this-&gt;execute();<br>   <strong>return </strong>$this-&gt;stmt-&gt;fetchAll(PDO::<em>FETCH_ASSOC</em>);<br>}</pre><p><strong>UPDATE</strong></p><p>just change the query</p><pre><strong>UPDATE &quot;table name&quot; SET &quot;column&quot; = &quot;new value&quot; WHERE &quot;condition&quot;;</strong></pre><p><strong>DELETE</strong></p><p>just change the query</p><pre><strong>DELETE &quot;table name&quot; WHERE &quot;condition&quot;;</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93dced2bc3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>