新来的,所以请放轻松。我有这个简单的 php 页面,当你使用它时,你输入你的用户名和密码。问题是我似乎无法重置它。基本背景是,数据库称为 My_Details,表称为 My_DetailsData。这是表单本身:
<form action="reset.php" method="post">
<p align="center">Type in below, your Username, Password and New Password to reset your login id.</p>
<table id="form_pword_reset">
<tr><td>Username</td><td>: <input type="text" name="USERNAME" /></td></tr>
<tr><td>Password</td><td>: <input type="password" name="PASSWORD_HASH" /></td></tr>
<tr><td>New Password</td><td>: <input type="password" name="PASSWORD_RESET" /></td></tr>
<tr><td></td><td> <input type="submit" value="Reset Password" /></td></tr>
</table>
</form>
它链接到页面上一个名为reset.php的php页面,一切正常,除了当我在html页面上更改密码时,数据库表根本不受影响......
$db_select=mysql_select_db("My_Details",$conn) or die(mysql_error());
//Retrieving data from html form
$username = $_POST['USERNAME'];
$password = $_POST['PASSWORD_HASH'];
$password_reset = $_POST['PASSWORD_RESET'];
//for mysql injection (security reasons)
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$password_reset = mysql_real_escape_string($password_reset);
$login = mysql_query("select*from My_DetailsData where USERNAME='$username' and PASSWORD_HASH='$password'");
if(mysql_num_rows($login)== 1){
mysql_query($conn, "UPDATE My_DetailsData SET PASSWORD_HASH=$password_reset WHERE USERNAME='$username' AND PASSWORD_HASH='$password'");
echo "Password Changed Successfully";
}
else{
echo "Incorrect Username or Password!";
}
mysql_close($conn);