title: Verify password hash using password_verify and MySQL
body: <p>I'm trying to store an encrypted password in MySQL and as for the register part it works as it should how ever when i try to do the login things go south.</p>
  
  <p>I can not verify $_POST['password'] against the hash stored in MySQL.
  I have no idea what I'm doing wrong.</p>
  
  <p>Here is my register.php which works as it should:</p>
  
  <p><strong>register.php (working)</strong></p>
  
  <pre><code>$post_password = mysqli_real_escape_string($_POST['password']);
  $password_hash = password_hash($post_password, PASSWORD_BCRYPT);
  mysqli_query goes here...
  </code></pre>
  
  <p><strong>login.php (not working)</strong></p>
  
  <pre><code>$con = mysqli_connect("XXX","XXX","XXX","XXX");
  $post_username = mysqli_real_escape_string($con,$_POST['username']);
  $post_password = mysqli_real_escape_string($con,$_POST['password']);
  
  // Getting the stored Hash Password from MySQL
  $getHash = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM anvandare WHERE username = '$post_username'"));
  $got_Hash = $getHash['password'];
  
  // Checking if what the user typed in matches the Hash stored in MySQL
  // **This is where it all goes wrong**
  if (password_verify($post_password, $got_Hash)) {
  echo "The posted password matches the hashed one";
  }
  else {
  echo "The posted password does not match the hashed one";
  }
  </code></pre>
  
  <p>When I run the code above I get the "Correct password" message <strong>by just entering the username</strong> and leaving the password field out.</p>
  
  <p>What am I missing?</p>