だから、私は非常に単純なリセット機能を作成しています。インデックス ページの 1 つのファイルは、次のような 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>
データベースをフォームに接続するもう 1 つのファイルは 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';}
?>