我无法在更改密码页面中将密码更新为新密码,而且完全没有错误,所以找不到哪个是不正确的部分。我检查了 MySQL 表,它没有更新。有人可以帮忙查一下吗?谢谢。
PHP代码
include "../setting/config.php";
session_start();
$btnchange = filter_input(INPUT_POST, "btnchange");
if(isset($btnchange))
{
$username = filter_input(INPUT_POST, "username");
$password = filter_input(INPUT_POST, "password");
$query2 = "SELECT username from registered_accounts where username='$username'AND password='$password'";
$query_run=mysqli_query($conn, $query2);
$level = mysqli_fetch_array($query_run);
if(count(fetchAll($query2)) > 0){ //this is to catch unknown error.
foreach(fetchAll($query2) as $row){
if ($row['username'] == $username && $row['password'] == $password)
{
$update_query2= "UPDATE registered_accounts set password='$password' where username='$username'";
$update_query_run=mysqli_query($conn, $update_query2);
if ($update_query2)
{
echo "<script>alert('Password has been changed successfully.')</script>";
}
else{
echo "<script>alert('Password has been failed to change.')</script>";
}
}
}
}
}
?>
身体
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<input type="text" class="text" name="username" placeholder="Username" value="" required autofocus>
<input type="password" placeholder="Password" name="password" value="" required autofocus>
<div class="submit"><input type="submit" value="Submit" name="btnchange"></div>
</form>
注册账户表
莫回无