我为用户创建了一种表格来更改编程的密码,如下所示-
include("../database.php");
if(isset($_SESSION['user_name']))
{
$password=$_POST['new_password'];
$query="select password from login where username = '".$_SESSION['user_name']."' and password='".md5($password)."'";
echo $query."<br>\n";
$result=mysql_query($query) or die(mysql_error());
echo $result."<br>\n";
echo "abc<br>\n";
echo mysql_num_rows($result)."<br>\n";
if(mysql_num_rows($result))
{
echo "def";
$row=mysql_fetch_row($result);
$pass=$row['password'];
echo $pass;
if($pass==$password)
{
$query2="UPDATE login SET password='$password' WHERE username='$_SESSION[user_name]'";
echo $query2;
echo "Password changed successfully";
}
else
{
echo "You entered wrong current password";
}
}
else
{
echo "here";
}
}
else
{
header('Location:index.php');
}
它给出了 $result=0。所以它不会更新用户密码。它直接转到其他部分并按书面形式给出“此处”的输出。什么是解决方案。