title: Login PHP doesn't select right user
body: <p>So, my problem is that I can't log in as any other user with my login script in PHP, it only selects the last row in the table. </p>
  
  <pre><code>&lt;?php
  require_once('core/config.php');
  if(isset($_POST['lSubmit'])) {
      $result = $mysqli-&gt;query("SELECT * FROM cms_users");
      while($row = $result-&gt;fetch_object() ) {
          $username = $row-&gt;username;
          $password = $row-&gt;password;
          $id = $row-&gt;id;
          $Rank = $row-&gt;Rank;
          $fail = "";
      }
      if($_POST['username'] == $username &amp;&amp; hash("SHA512", "SHA512", $_POST['password'] + "QxLUF1bgIAdeQX") == $password) {
          $_SESSION['username'] = $username;
          $_SESSION['id'] = $id;
          header("Location: index.php?ID=$id&amp;Username=$username");
      } else 
          header("Location: login.php?fail=true");
          $fail = "Username and/or password is wrong!";
     }
  } else {
      header("Location: login.php");
      $fail = "Username and/or password is wrong!";
  }
  </code></pre>