title: Creating a very simple 1 username/password login in php
body: <p>I want to make a single login for just 1 user without storing in a database but I can't seem to get this to work. </p>
  
  <p>My code: login.php</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;
      &lt;h3&gt;Add entry&lt;/h3&gt;
      &lt;p&gt; Add another Article&lt;/p&gt;
      &lt;form action="trylog.php" method = "post"&gt;
          &lt;label for="username"&gt;Username&lt;/label&gt; &lt;input type="username" id="usename" name="username"&gt;&lt;br /&gt;&lt;br /&gt;
          &lt;label for="password"&gt;Password:&lt;/label&gt; &lt;input type="text" id="password" name="password"&gt;&lt;br /&gt;&lt;br /&gt;
          &lt;button type = "submit"&gt;Login&lt;/button&gt;
      &lt;/form&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>trylog.php</p>
  
  <pre><code>&lt;html&gt;
      &lt;title&gt;Login&lt;/title&gt;
      &lt;body&gt;
          &lt;?php
          $usr = "admin";
          $psw = "password";
          $username = '$_POST[username]';
          $password = '$_POST[password]';
          //$usr == $username &amp;&amp; $psw == $password
          session_start();
          if ($_SESSION['login']==true || ($_POST['username']=="admin" &amp;&amp; $_POST['password']=="password")) {
              echo "password accepted";
              $_SESSION['login']=true;
          }else {
              echo "incorrect login";
          }
          ?&gt;
  
          &lt;form name="input" action="adminportal.php" method="get"&gt;
              &lt;input type="submit" value="Home"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>