我有一个登录表单,当密码输入错误但电子邮件不正确时会显示一条消息。但是当电子邮件或两者都不正确时,它不会显示任何内容。我希望它在这两种情况下都显示消息(“密码和电子邮件不匹配”)丢失。我真的很感激任何帮助。
<div id="container">
<div>
<h1>Log In</h1>
<form method="POST" action="logIn.php">
<label>Email</label>
<input name= "txtEmail"/>
<label>Password</label>
<input type="password" name="txtPass"/>
<input type= "submit" name= "submit" value="Log In"/>
</form>
</div>
</div>
<?php
require ('connection.php');
if (isset($_POST["txtEmail"]))
{
$email= $_POST["txtEmail"];//NO RECONOCE LOS TEXT FIELDS!!
}
else
{$email= "";
echo "Email empty";}
if (!empty($_POST['txtPass']))
{
$pass= $_POST['txtPass'];
}
else
{$pass= "";
echo "Password empty.";}
// Enviar consulta
$instruction = "SELECT Password, Email FROM customer WHERE Email = '". $email . "'";
$query = mysql_query ($instruction, $connection)
or die ("Fallo en la consulta");
// Mostrar resultados de la consulta
$nrows = mysql_num_rows ($query);
if ($nrows > 0)
{
$result = mysql_fetch_array ($query);
if (isset($result['Password']))
{
$clave = $result['Password'];
//echo "Isset password works.";
}
else {$result= "";}
Email doesnt exist, or ;}
if ($clave == $pass){
header('Location: welcomeLogIn.php');
}
else{
echo "Password or Email doesnt match.";
}
}
mysql_close($connection);
?>