0

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

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");
}
?>
4

1 回答 1

0

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

$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']."";
于 2013-06-05T06:58:42.120 回答