它在数据库中找不到正确的电子邮件地址


It cannot find the correct email address in the database

我想检查一个有效的电子邮件地址,然后查看该电子邮件地址是否在数据库中。目前,有效电子邮件地址的验证工作正常。但如果我输入数据库中的电子邮件地址,例如"nickfrosty@yahoo.com",它没有回显消息You have entered in the Correct Email Address,而是回显完全相反的消息并回显You entered in the Wrong Email Address。因此,这让我认为,即使我确信电子邮件地址在数据库中,它也无法在数据库中找到电子邮件地址。

所以我的问题是,为什么它不能在数据库中找到电子邮件地址,从而回复我在错误的电子邮件地址中输入的消息?

下面是代码(mysqli/php):

if ( (strlen($email) >= 7) && (strstr($email, "@")) && (strstr($email, ".")) ){
echo "You have entered in the Correct Email Address";
}
else{
echo "You entered in the Wrong Email Address";
}
$query = "SELECT TeacherUsername, TeacherEmail FROM Teacher WHERE TeacherUsername = ?";

意味着您根据TeacherUsername而不是TeacherEmail检查输入。你可能想试试

$query = "SELECT TeacherUsername, TeacherEmail FROM Teacher WHERE TeacherEmail = ?";
相关文章: