很抱歉在这里问愚蠢的问题。问题是我没有收到错误消息。我的意思是,如果电子邮件或密码不正确,我想打印这一行:
'{"status":"false","message":"Login incorrect. Try again"}';
我已尝试过此代码。
else if($email != $dbemail || $password != $dbpassword) { return '{"status":"false","message":"Login incorrect. Try again"}'; }
但没有得到别的消息。
if ($checkDevice != 0 ) {
$email = $get['email'];
$password = $get['password'];
$stmt = $con->prepare("SELECT * FROM users WHERE email = ? AND password = ? ");
$con->errorInfo();
$stmt->bindParam('1', $email, PDO::PARAM_STR);
$stmt->bindParam('2', $password, PDO::PARAM_STR);
$stmt->execute();
$num_rows = $stmt->rowCount();
// print_r($get);
if($num_rows != 0 )
{
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
$dbemail = $row['email'];
$dbpassword = $row['password'];
}
if($email == $dbemail && $password == $dbpassword)
{
return '{"status":"true","message":"Success. Login details correct."}';
}
else
{
return '{"status":"false","message":"Login incorrect. Try again"}';
}
}
}