I want to compare my password and my hash password with password_verify()
but always returns true
.Why is that happening?
Here is the code:
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($db,$_POST['username']);
$mypassword = mysqli_real_escape_string($db,$_POST['password']);
$hash = password_hash($mypassword, PASSWORD_DEFAULT);
$ourdb = "SELECT handle FROM qa_users WHERE handle = '$myusername' and passhash = '$mypassword'";
$ourresult = mysqli_query($db,$ourdb);
$ourrow = mysqli_fetch_array($ourresult,MYSQLI_ASSOC);
$ouractive = $ourrow['active'];
$ourcount = mysqli_num_rows($ourresult);
if(password_verify($mypassword, $hash)){
echo "hashed";
}