if ( $row = mysql_fetch_array($result) )
{
                $_SESSION['user']=$name;
}
改成这样试试~~不行的话~~我把我的登陆程序发给你

解决方案 »

  1.   

    if (isset($name))-------------
    else
      

  2.   

    if(isset($_SESSION['user']))
    {
    echo "<script>alert('登陆成功!');window.location='u_expense.php';</script>";
    }
    else
    {
    echo "<script>alert('请输入正确的资料!');window.location='login.php';</script>";
    }
      

  3.   

    什么用户名?????我在数据库先打进两条记录..一条的用户名是;test密码一样 ..密码用MD5加密过.
      

  4.   

    user_id  user_name  user_passwd  
    2 test 098f6bcd4621d373ca
      

  5.   

    <?php
    session_start();if (isset($_POST['user_name']) && isset($_POST['user_passwd']))
    {
    $name=$_POST['user_name'];
    $pass=md5($_POST['user_passwd']);
    include("config/dbconn.php");
    $query="select * from ab_user where user_name='$name' and user_passwd='$pass'";$result=mysql_query($query);
    if(mysql_num_rows($result) > 0)
    {
    $_SESSION['user']=$name;
    }
    if(isset($_SESSION['user']))
    {
    echo "<script>alert('登陆成功!');window.location='u_expense.php';</script>";
    }
    else
    {
    echo "<script>alert('请输入正确的资料!');window.location='login.php';</script>";
    }
    }
      

  6.   

    <?php
    session_start();if (isset($_POST['user_name']) && isset($_POST['user_passwd']))
    {
        $name=$_POST['user_name'];
        $pass=md5($_POST['user_passwd']);
        include("config/dbconn.php");
        $query="select * from ab_user where user_name='$name' and user_passwd='$pass'";   $result=mysql_query($query);
       if(mysql_num_rows($result) > 0)
       {
         mysql_free_result($result);
         $_SESSION['user']=$name;
         echo "<script>alert('登陆成功!');window.location='u_expense.php';</script>";
       }else
      {
        mysql_free_result($result);
        echo "<script>alert('请输入正确的资料!');window.location='login.php';</script>";
      }}
    exit;?>
      

  7.   

    我怀疑是MYSQL有问题.无论怎么输入就是显示请输入正确资料..可是,那个select明明没有问题...
      

  8.   

    分析了很多原因,我估计就是$_SESSION['user']的值为空....为什么会这样呢....
      

  9.   

    check the username and the password  exists in mysql