我还是 PHP 新手。我尝试了 Andrew Moore 先生的方法。密码不匹配。我尝试使用Andrew Liu 的代码 和帖子中的答案。当我尝试 var_dump 时,我没有得到真或假。我不确定我做错了什么。有人可以告诉我吗?
$bcrypt = new Bcrypt(15);
$username = sanitize($username);
$password = $_POST['password'];
DEFINE('DB_USER', 'root');
DEFINE('DB_PASSWORD', 'password');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_NAME', 'users');
$dbh = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$check_username = $dbh->prepare("SELECT password FROM user WHERE username= '$username'");
$check_username -> execute(array($username));
while($row = $check_username->fetch(PDO::FETCH_ASSOC)){
$check_password = $row['password'];
$isGood = $bcrypt->verify($password, $check_password);
var_dump($isGood);
}