当我尝试使用现有帐户登录时,代码运行正常,但是当我尝试使用不存在的帐户登录时,它应该执行else
部分和echo
消息,但它仍然执行块中定义的if
部分。为什么?
欢迎任何其他提示
$sql = "SELECT email,password,id FROM user WHERE email=? AND password=?";
$stm = $db->prepare($sql);
$stm->execute(array($email,$password));
$row = $stm->fetch(PDO::FETCH_ASSOC);
$number_of_rows = $stm->fetchColumn();
if(count($number_of_rows)==1){
$_SESSION['id']=$row['id'];
header('Location: cpanel/#welcome');
}else{
echo "<font style='background-color: #F9C5CA'>Error: Your email and/or password are incorrect. Please try again.</font>";
}