我是一个初学者在PHP中,也许问题是如此简单,但是当我尝试从我的分贝获得哈希,并让密码验证做所有的工作,它总是给我假,即使使用正确的密码。我试图复制粘贴哈希从数据库并把它放在密码验证,它的工作。密码验证与查询不工作
$sql="SELECT * FROM users WHERE username='$myusername'";
$result=mysqli_query($connection,$sql);
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If result matched $myusername, table row must be 1 row
if($count==1){
//This must be the problematic place
$hash = mysqli_query($connection,"SELECT jelszo FROM users WHERE username =='$myusername'");
if(password_verify($myjelszo,$hash))
{
// Register $myusername, $myjelszo and redirect to file "login_success.php"
$_SESSION['username']= "myusername";
$_SESSION['jelszo']= "myjelszo";
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
为什么不能从单个查询中获取所有详细信息 – Akintunde007
您错误地使用了密码哈希函数。你为什么不读这个用法。在函数中,将散列密码作为第一个参数,输入密码作为第二个参数 – Akintunde007