db
の唯一のユーザーのログインコードを書きます。 しかし、password_verify
関数が機能していないようです。 echo
db
のhash
と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 "] =>文字列(6)" bcrypt "[" options "] => array(1){[ "cost"] => int(12)}} – TheTryHardz