所以这是我更新忘记密码的人的密码。问题是,当用户提交新密码时,要么所有密码都改为他写的新密码,除了他的密码,或者什么也没发生。
这是我的代码:
<?php
require('connect.php');
$codeee = $_GET["recov"];
$paso = $confpaso = "";
$pasoErr = $confpasoErr = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["paso"])) {
$pasoErr = "Password is required";
} else {
$paso = md5(test_inputing($_POST["paso"]));
}
$confpaso = md5(test_inputing($_POST["confpaso"]));
if($confpaso != $paso) {
$confpasoErr = "Passwords do not match";
}
if($pasoErr == $confpasoErr && $confpasoErr == "") {
$changepaso = "UPDATE users SET password = '$paso' WHERE forgotcode = '$codeee'";
if ($conn->query($changepaso) === TRUE) {
$tellthem = "Password Changed";
} else {
$tellthem = "Something Happened, the password was not changed";
}
}
}
function test_inputing($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
所以我开始尝试一切来找出问题所在,我发现$ _GET值的$ codeee变量只能在“if($ _ SERVER [”REQUEST_METHOD“] ==”之外工作POST“)”声明。因此在$ changepaso查询中,$ codeee的值不存在。谁能告诉我如何解决这个问题?感谢