i'm working on a passowrd reset but the issue i'm having is that when ever the password is about to get update for some reason it changes here is my code
>?php
if ($password == $confirmpassword)
{
echo "$password";
echo "</br>";
//has and secure the password
$npassword = password_hash('$password', PASSWORD_BCRYPT, array('cost' => 10));
echo "$npassword";
// Update the user's password
$query = $conn->prepare('UPDATE users SET password = :password WHERE email = :email');
$query->bindParam(':password', $npassword);
$query->bindParam(':email', $email);
$query->execute();
$conn = null;
echo "Your password has been successfully reset.";
}
else
echo "Your password's do not match.";
}
?>
example im trying to use demo123 as password when i echo $password i do get demo123, when i echo $npassword i get a code and when i manually do
>?php $npassword = password_hash('demo123', PASSWORD_BCRYPT, array('cost' => 10));?>
i get another hash Now this has does work if i add it manually if i use the variable $password i get another code wrong by the way cause i cant login but if i do it manual and update it then demo123 works.
what am i doing wrong, I'm a newbie