title: PHP Login Counter
body: <p>Im having a problem for retaining variables. I guess when you submit a form the variables will be reset to default. so I dont know how to make a limit of 3 login attempts only before it says "Go Away! Hacker!". With just using php and nothing else.
  Anyone has a clue? Don't worry for Security because this is just an example of exercise my prof gave us and we need to do it with just php alone. so dont worries about hackers resetting cookies. </p>
  
  <p>NOTE: I'm only using XAMPP to make php work in localhost.</p>
  
  <p>Here's the Code in PHP:</p>
  
  <pre><code>&lt;center&gt;&lt;form action="" method="post"&gt;&lt;br&gt;
  User ID: &lt;input type="text" name="id"&gt;&lt;br&gt;
  Password: &lt;input type="password" name="pass"&gt;&lt;br&gt;
  &lt;input type="submit" name="submit" value="login"&gt;
  &lt;/form&gt;
  
  &lt;?php
  if(isset($_POST['submit'])){
      $counter = 0;
      $counter++;
      $vid = 'hanzo';
      $vpass = '123456';
      $id = $_POST['id'];
      $pass = $_POST['pass'];
      $c = "&lt;center&gt;";
      if(empty($id)) echo "$c Please Input Username.&lt;br&gt;";
      else if(empty($pass)) echo "$c Please Input Password.&lt;br&gt;";
      else if($vid==$id &amp;&amp; $vpass==$pass) echo "$c Login Succesfully&lt;br&gt;";    
      else if($counter&gt;3) echo "$c Go Away! Hacker!&lt;br&gt;";
      else echo "$c Invalid Username/Password&lt;br&gt; Login Attempt: $counter";
  }
  ?&gt;
  </code></pre>