我正在为我的db
中的唯一用户写入登录代码。 但password_verify
函数似乎不起作用。当我在echo
这两个hash
从db
和password
写在窗体,我看到他们,所以没有问题的查询或$_POST
。password_verify不起作用,即使它具有散列和用户密码
这里是我的代码: 日志中:提前
$passwordFromForm = htmlspecialchars($_POST['password']);
$nmbr = 12; // it's the user's id.
$sql = "SELECT * FROM user WHERE iduser = $nmbr";
$res = mysqli_query($conn, $sql);
// $row = mysqli_fetch_assoc($res);
while($row = $res->fetch_assoc()) {
$hashFromDB = $row['hash'];
}
if(password_verify($passwordFromForm, $hashFromDB)) {
echo "success";
header("Location: ../admin.php");
}
else {
echo "The hash is:" . $hashFromDB . "and the pass is:" . $passwordFromForm;
//this echoes the correct hash and string
}
感谢。
谢谢! 如果password_verify的散列与password_hash的散列相同? 他们是一样的。 – TheTryHardz
这是password_get_info: array(3){[“algo”] => int(1)[“algoName”] => string(6)“bcrypt”[“options”] => array(1){[ “cost”] => int(12)}} – TheTryHardz