gpt4 book ai didi

mysql - SQL查询失败[密码更改]

转载 作者:行者123 更新时间:2023-11-30 01:35:38 26 4
gpt4 key购买 nike

我正在我的网站上工作,我正在尝试创建一个允许他们更改密码的设置页面,但是每次我尝试更改密码时,它都会显示查询失败,如果您能发现问题,将会有很大帮助;

require_once('config.php');
require_once('auth.php');


$errmsg_arr = array();


$errflag = false;


$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}


$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$password = clean($_POST['password']);
$retpassword = clean($_POST['retpassword']);


if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($retpassword == '') {
$errmsg_arr[] = 'Please retype your password';
$errflag = true;
}
if( strcmp($password, $retpassword) != 0 ) {
$errmsg_arr[] = 'New passwords do not match!';
$errflag = true;
}

//If there are input validations, redirect back to the settings page
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: settings.php");
exit();
}


$qry = "UPDATE members SET passwd = ".md5($_POST['password'])." WHERE member_id = ".$_SESSION['SESS_MEMBER_ID']."";
$result = @mysql_query($qry);


if($result) {
header("location: changed.php");
exit();
}else {
die("Query failed");
}
?>

最佳答案

只是在黑暗中拍摄,因为我不知道错误消息,而不是:

$qry = "UPDATE members SET passwd = ".md5($_POST['password'])." WHERE member_id =  ".$_SESSION['SESS_MEMBER_ID']."";

使用这个(您忘记将密码括在单引号中):

$qry = "UPDATE members SET passwd = '".md5($_POST['password'])."' WHERE member_id =  ".$_SESSION['SESS_MEMBER_ID']."";

关于mysql - SQL查询失败[密码更改],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16933403/

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