以下是我的密码处理程序的代码
protected function passwordMatch($username, $password)
{
$sql = 'SELECT `username`, `password` FROM `profile` WHERE `username` = ?';
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$username]);
$result = $stmt->fetch();
if (password_verify($result['password'], $password)) {
return true;
}
return false;
}
if ($this->passwordMatch($this->username, $this->password) !== true) {
$_SESSION['error'] = 'Password not matching';
header('Location: ../login.php');
exit();
}
预期:如果用户名和密码匹配,则用户将登录
try :我try 从!==
更改为===
,看看这是否可以解决问题,但即使密码不匹配,它也会让用户登录,否则我无法判断我的代码出了什么问题
如果你想在这里看到完整的代码:https://github.com/sammo-2000/login