gpt4 book ai didi

php - 为什么此更新用户密码的代码不起作用?

转载 作者:行者123 更新时间:2023-11-29 08:08:23 25 4
gpt4 key购买 nike

<?php
include_once 'db.php';
session_start();
if(!$_SESSION['logged_in']) {
die('You are unauthorized to be here. 1');
}
$old_password = md5($_POST['old_password']);
$new_password = md5($_POST['new_password']);
$sql = "UPDATE users SET pass='?' WHERE user='?' AND pass='?'";
$q = $db->prepare($sql);
$q->bindParam(1, $new_password);
$q->bindParam(2, $_SESSION['username']);
$q->bindParam(3, $old_password);
$q->execute();
header('location: ../?page=account');
?>

这是我的“用户”表方案:

 `users` (`active` int(1) NOT NULL DEFAULT '1',
`user` varchar(200) NOT NULL,
`pass` varchar(200) NOT NULL,
`admin` int(1) NOT NULL,
`date` varchar(150) NOT NULL DEFAULT 'error',
`Paid` varchar(200) NOT NULL DEFAULT 'None',
KEY `user` (`user`) )
ENGINE=MyISAM DEFAULT CHARSET=latin1;

它根本不更新值...有什么想法吗?

最佳答案

从占位符中删除引号。

关于php - 为什么此更新用户密码的代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22247591/

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