Php 河豚密码\u验证不起作用
我正在用Anthony Ferrara的密码压缩库用河豚散列我的密码。当我散列它们时,它们是好的,但是当我尝试验证密码时,执行以下操作:Php 河豚密码\u验证不起作用,php,Php,我正在用Anthony Ferrara的密码压缩库用河豚散列我的密码。当我散列它们时,它们是好的,但是当我尝试验证密码时,执行以下操作: public function Login($username, $postpassword) { $stmt = $this->mysqli->prepare("SELECT username, password FROM users WHERE username=? AND password=?"); $stmt->bi
public function Login($username, $postpassword) {
$stmt = $this->mysqli->prepare("SELECT username, password FROM users WHERE username=? AND password=?");
$stmt->bind_param('ss', $username, $password);
$stmt->execute();
$stmt->bind_result($username, $password);
$stmt->store_result();
if($stmt->num_rows == 1) {
while($stmt->fetch()) {
if (password_verify($postpassword, $password)) {
$SESSID = $this->newSession($username);
$_SESSION['admin_user'] = $username;
$_SESSION['last_login'] = time();
header("Location: home.php?SESSID=$SESSID");
exit();
}
}
}
else {
header("Location: index.php?e=false");
exit();
}
$stmt->close();
$stmt->free_result();
}
它告诉我细节是错误的。。。是的,我确实定义了$username和$password:
有人看到我犯的错误了吗?您正在从数据库中选择用户,其中用户名与输入的用户名匹配,密码哈希与输入的明文密码匹配。当然,这永远不会匹配任何东西。您必须仅根据用户名从数据库中选择用户名和密码,然后使用password\u verify验证密码。您是从数据库中选择用户,其中用户名与输入的用户名匹配,密码哈希与输入的明文密码匹配。当然,这永远不会匹配任何东西。您必须仅根据用户名从数据库中选择用户名和密码,然后使用password_verify验证密码。因此,它将类似于选择用户名、用户名为“”的用户的密码,也将类似于选择用户名、用户名为“”的用户的密码??
if(isset($_REQUEST['login'])) {
$username = $_POST['username'];
$postpassword = $_POST['password'];
$users->Login($username, $postpassword);
}