gpt4 book ai didi

php - 使用 php/mysql 更新密码

转载 作者:太空宇宙 更新时间:2023-11-03 11:48:52 26 4
gpt4 key购买 nike

昨天我发布了一些代码,询问用户如何通过表单更新密码。看here

但是在更新密码后,我无法通过我的 android 应用程序登录。所以我决定稍微更改一下 forgotpassword.php 文件。

<?php
session_start();
require "../init.php";
ini_set('display_errors', 1);



if(isset($_POST['update'])){


$email = $_POST['email'];
$user_name = $_POST['user_name'];
$password = $_POST['user_pass'];
$passwordEncrypted = sha1($user_pass);

$confpassword = $_POST['confirm_pass'];
$confPasswordEncrypted = sha1($confirmPass);

if($password !== $confpassword){
echo "<script>alert('Passwords are not equal')</script>";
}else{
$select_query = "SELECT * FROM user_info";

$run_select_query = mysqli_query($con,$select_query);

while ($row_post=mysqli_fetch_array($run_select_query)){

$_SESSION['id'] = $row_post['id'];
$user_id = $_SESSION['id'];
$useremail = $row_post['email'];
$username = $row_post['user_name'];

var_dump($user_id);

if($useremail == $email AND $username == $user_name){
//echo "<script>alert('$useremail')</script>";
//echo "<script>alert('$username')</script>";
echo "<script>alert('$id')</script>";
$update_posts = "UPDATE user_info SET user_pass='$passwordEncrypted',confirm_pass ='$confPasswordEncrypted'
WHERE $id='$_userid'";

$run_update = mysqli_query($con,$update_posts);
//var_dump($user_name);
echo "<script>alert('Password Has been Updated!')</script>";
}else{
echo "<script>alert('No email or username was found')</script>";
}

}

}

}
?>

但是现在密码没有像以前那样更新了。更新语句或之前的一行有问题。 $_SESSION['id'] 不为空,因此选择查询工作正常。

有什么想法吗?

谢谢。

最佳答案

where 子句中的拼写错误。 WHERE $id='$userid'";

将更新查询 where 子句更改为:WHERE $id='$user_id'";

关于php - 使用 php/mysql 更新密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36786627/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com