所以,我正在创建一个非常简单的重置功能。索引页面上的一个文件只是一个 html 表单,如下所示:
<html>
<body>
<div>
<form id="reset" action="login/reset.php" method="post">
<fieldset>
<label for="reset-email"> Enter your e-mail address here :</label>
<input type="text" name="SignupEmailAdd" id="login-email" /><br />
<label for="reset-password"> Enter your new password here :</label>
<input type="password" name="SignupPassword" id="reset-password" /><br />
<input type="submit" id="reset-button" value="Reset my password!" />
</fieldset>
</form>
</div>
</body>
</html>
将数据库连接到表单的另一个文件称为 reset.php,它具有以下功能:
<? php
session_start();
mysql_connect('localhost','root','password');
mysql_select_db('testproject');
$SignupEmailAdd = $_POST['SignupEmailAdd'];
$SignupPassword = $_POST['SignupPassword'];
if($SignupPassword)
$sql=mysql_query("UPDATE users SET SignupPassword='$SignupPassword' where SignupEmailAdd='$SignupEmailAdd'");
if($sql)
{
echo 'Congratulations You have successfully changed your password.
<br /><a href= "http://www.bla.com/">Click here to go back to the login page.</a>';
}
else
{
echo 'The email address you've entered does not exist';.
}
?>
您会看到除了我的 else 功能外一切正常。它不会显示消息“电子邮件地址..不存在”,而是显示“恭喜..”。我可以用我的 else 语句做什么?我也试过这个而不是别的:
<?php
if(!$sql){echo 'The username you entered does not exist';}
?>