有人可以帮忙吗,我有这个更改密码脚本,允许用户更改密码。
目前它允许用户更改他们的密码,尽管他们在旧密码框中输入了什么。有人可以告诉我如何检查旧密码是否与“ptb_users.password”中存储的密码匹配吗?
它目前还允许用户将密码设置为空,有没有办法让我强制输入 enw 密码和确认密码字段?
谢谢。
<?php
require_once("session.php");
require_once("functions.php");
require('_config/connection.php');
?>
<?php
session_start();
include '_config/connection.php';
$password = md5($_POST['password']);
$newpassword = md5($_POST['newpassword']);
$result = mysql_query("SELECT password FROM ptb_users WHERE id=".$_SESSION['user_id']." AND password = '".$password."'");
if(!$result)
{
echo "The username you entered does not exist or old password didn't match";
}
else
{
$sql=mysql_query("UPDATE ptb_users SET password='$newpassword' WHERE id=".$_SESSION['user_id']."");
}
if($sql)
{
echo "Thank You. Your Password has been successfully changed.";
}
?>