重置密码表单不会更新密码

时间:2015-04-10 09:31:14

标签: php mysql sql-update

<?php
session_start();

if(!isset($_SESSION['name'])){
echo "You are logged in already. Try resetting your password instead.";
}else{

echo "

<html>

<head>
<title>Login Page</title>
<link href='css/global.css' type='text/css' rel='stylesheet'>
</head>

<body>

</body>

<form method='POST' action='./resetpass.php'>
<table border='0' width='15%'>
<h3>Please enter your email so we can send you a link to reset your password.</h3>
<tr><td> Email Address: </td><td><input type='text' name='password' maxlength='40' placeholder=' Your Email Address' /></td></tr><br />
</table>
<p>
<input type='submit' value='Reset Password' /><br />
</form>

</html>

";
}
?>
<?php
include('fnc/connect.php');
error_reporting(E_ALL);
ini_set('display_errors', 1);
if(isset($_POST['submit'])){

$email = $_POST['password'];

mysqli_query($conn, "UPDATE users SET password='23' ");


}else{
     echo "failed";
}

?>

但代码不会更新数据库中的密码。请忽略HTML表单中的“电子邮件”地址,因为我从其他表单复制它以进行测试。我只需要知道为什么我输入文本框的文本不会更新数据库中的当前密码,而是将其清空。

感谢。

1 个答案:

答案 0 :(得分:3)

因为您错过了设置提交按钮的名称而您正试图获取的是..

替换此

<input type='submit' value='Reset Password' />

到这个

<input type='submit' name='submit' value='Reset Password' />