I hashed my password using password_hash()
, and verify using password_verify();
When i write the hash directly in variable the value be True
$hash = '$2y$10$lKwHxxc1YJI01ftNe33pcOvddAVrLd0GHwb3Ya3eqQJ2HxycpHjpO';
But When i call the value from MySQL the value be false when i put it in this function , i make echo for the value and the value been true , but i don't know why being false when i put it in password_verify();
I look for all previous questions about this problem but i didn't found any answer, this is my code
if(isset($_POST['submit'])=="Log In") {
$password = 'aliali12';
$sql = mysqli_query($con, "SELECT * FROM users WHERE user_id = 1");
$hashed_pass = mysqli_fetch_assoc($sql);
if (password_verify("$password",$hashed_pass['user_pass'])){
echo "Correct Password";
} else {
echo 'There are some wrong';
}
}
Edit:
Here is the code that was used to hash the password with:
$password = mysqli_real_escape_string($con, $_POST['changePassword']);
$hash = password_hash("$password", PASSWORD_BCRYPT)."\n";