各位大佬们,为什么PHP新闻发布系统中已经注册好的用户无法登录,总是显示密码错误,但是数据库有字段存在。。。

图片说明图片说明图片说明图片说明
以下是login_users_process.php的代码:
<?php
session_start();
include_once("functions/database.php");
$name = $_POST["name"];
if($_POST["checknum"] != $_SESSION["checknum"]){
header("Location:index_users.php?login_message=checknum_error");
return;
}
if(isset($_COOKIE["password"])){
$first_password = $_COOKIE["password"];
}else{
$first_password = md5($_POST["password"]);
}
if(empty($_POST["expire"])){
setcookie("name",$name,time()-1);
setcookie("password",$first_password,time()-1);
}
$password = md5($first_password);
$sql = "select * from users where name='$name' and password ='$password'";
get_connection();
$result_set = mysql_query($sql);
if(mysql_num_rows($result_set)>0){
if(isset($_POST["expire"])){
$expire = time()+intval($_POST["expire"]);
setcookie("name",$name,$expire);
setcookie("password",$first_password,$expire);
}

$users = mysql_fetch_array($result_set);
$_SESSION['user_id'] = $users['user_id'];
$_SESSION['name'] = $users['name'];
header("Location:index_users.php?login_message=password_right");
}else{
header("Location:index_users.php?login_message=password_error");
}
close_connection();
?>

以下是login_users.php 的代码
<?php
session_start();
include_once("functions/database.php");
include_once("functions/is_login.php");
if(isset($_GET["login_message"])){
if($_GET["login_message"]=="checknum_error"){
echo "验证码错误,重新登录!
";
}else if($_GET["login_message"]=="password_error"){
echo "密码错误,重新登录!
";
}else if($_GET["login_message"]=="password_right"){
echo "登录成功!
";
}
}
if(is_login()){
echo "欢迎".$_SESSION['name']."访问系统!
";
echo "注销";
return;
}
$name = "";
if(isset($_COOKIE["name"])){
$name = $_COOKIE["name"];
}
$password = "";
if(isset($_COOKIE["password"])){
$password = $_COOKIE["password"];
}
?>

用户名:
密 码 :
验证码:
Cookie保存1小时

$password = md5($first_password);
你的密码是明文存放在数据库里的
可你判断的时候做了一个md5
两者不一致。

mysql_num_rows($result_set)>0 你先判断下这里成立吗?不成立就是前面的问题,输出下$result_set = mysql_query($sql); 的结果看看,如果成立就是后面的问题,可以一步步的测试找问题

$first_password = md5($_POST["password"]);

的md5也去掉试试