php - How to get password_verify to work for me -
using password_hash() able hash password , store long string in database.
however, when try use password_verify(), having trouble confirming value entered matches hashed value stored in database can log in.
$uid = $_post['uid']; $pwd = $_post['pwd']; $sql = "select * user uid='$uid'"; $result = $conn->query($sql); $row = $result->fetch_assoc(); $hash_pwd = $row['pwd']; if (password_verify($pwd, $hash_pwd)) { $sql = "select * user uid='$uid' , pwd='$hash_pwd'"; $result = $conn->query($sql); if (!$row = $result->fetch_assoc()) { echo "your username or password incorrect!"; } else { $_session['id'] = $row['id']; } }
Comments
Post a Comment