当用户在表单中填写他们的电子邮件地址时,我会检查数据库中是否存在该电子邮件地址。
为什么代码不起作用?
这是我的代码:
PHP
{{1}}
答案 0 :(得分:1)
你必须回应结果,看看if / else是否像这样
session_start();
require 'database.php';
if(!empty($_POST['email']) ):
$records = $conn->prepare('SELECT id,email,password FROM users WHERE email = :email');
$records->bindParam(':email', $email);
$records->execute();
$results = $records->fetch(PDO::FETCH_ASSOC);
$message = '';
if(count($results) > 0 && password_verify($_POST['password'], $results['password']) ){
$message = 'Success!';
} else {
$message = 'Sorry, those credentials do not match';
}
// Now, you just have to add
echo $message;
endif;