<?php
/*系统登录处理页*/
require_once("Conn_DB_zzh.php");//包含数据库连接文件
if($_POST["txt_username_zzh"]!="" && $_POST["txt_pwd_zzh"]!="")//判断用户名密码是否为空
{
$name_zzh = $_POST["txt_username_zzh"];
$pwd_zzh = $_POST["txt_pwd_zzh"];
$str = "select * from admin_info_czl where A_Username_czl='$name_zzh' and  A_Password_czl='$pwd_zzh'";
//echo" $str";//本语句用于调试,输出查询语句
$result = mysql_query($str);//执行SQL语句
if(mysql_num_rows($result)>0)//判断返回记录的行数
{
session_start(); //登录成功,设置SESSION值

$_SESSION['user'] = $_POST['txt_username_zzh'];
echo "<script> window.location.href='main_zzh.php';</script>";//跳转到管理平台
}
else//登录失败,弹出提示对话框,返回登录页
{
echo "<script>alert('用户名或密码错误!');window.location.href = 'login_zzh.php'</script>";
}
}
else //用户名和密码为空,弹出提示对话框,返回登录页
{
echo "<script>alert('请输入用户名和密码!');window.location.href = 'login_zzh.php'</script>";
}

?>

解决方案 »

  1.   

    数据库错误吗?$result = mysql_query($str) or die(mysql_error());//执行SQL语句看看有什么错误提示。
      

  2.   

    数据库错误吗?$result = mysql_query($str) or die(mysql_error());//执行SQL语句看看有什么错误提示。
    if($_POST["txt_username_zzh"]!="" && $_POST["txt_pwd_zzh"]!="")//判断用户名密码是否为空
    {
    改为if(isset($_POST["txt_username_zzh"]) && $_POST["txt_username_zzh"]!="" && isset($_POST["txt_pwd_zzh"]) && $_POST["txt_pwd_zzh"]!="")//判断用户名密码是否为空
    {