$sql="select * from wyx_user where wyx_name='$wyx_name'&&wyx_pass='$wyx_pass'";改成
$sql="select * from wyx_user where wyx_name='$wyx_name' AND wyx_pass='$wyx_pass'";

解决方案 »

  1.   

    如果成功过的话,证明程序应该没有错误。
    在php中var_dump一下$_POST['wyx_name']和$_POST['wyx_pass']、$sql
    还有sql的搜索结果,看看怎么回事先。
      

  2.   


    var_dump不会用啊,菜鸟刚学
      

  3.   

    echo $sql ;输出sql语句看看,
    可能是你用户名或是密码错误了
      

  4.   


    结果显示:Resource id #3咋回事?
      

  5.   

        $wyx_name = $_POST['wyx_name'];
        $wyx_pass = md5(trim($_POST['wyx_pass']));
        $sql="select * from wyx_user where wyx_name='$wyx_name'&&wyx_pass='$wyx_pass'";
        $sql=@mysql_query($sql);
        $rs=@mysql_fetch_array($sql);
        if($rs)
        {
            setcookie("wyx",$wyx_name,time()+3600000);
            header("Location:admin_index.php");
        }
        else
        {
            $str="<SCRIPT language=JavaScript>alert(' 用户名或密码错误!');javascript:history.go(-1)</SCRIPT>";
            echo $str;
        }
      

  6.   

    <?php
    include('../config.php');
    //验证码
    $pageRandCode=$_POST['wyx_yzm'];
    session_start();
    if($_SESSION['verifyCode'] <> $pageRandCode)
    {  
        echo '<script>alert("验证码有误!");   
        location.replace ("index.php")</script>';   
    }
    else
    {
        $wyx_name = $_POST['wyx_name'];
        $wyx_pass = md5(trim($_POST['wyx_pass']));
        $sql="select * from wyx_user where wyx_name='$wyx_name'and wyx_pass='$wyx_pass'";
        echo $sql;
        $query=@mysql_query($sql);
        if($rs=@mysql_fetch_array($query))
        {
            setcookie("wyx",$wyx_name,time()+3600000);
            header("Location:admin_index.php");
        }
        else
        {
            $str="<SCRIPT language=JavaScript>alert(' 用户名或密码错误!');javascript:history.go(-1)</SCRIPT>";
            echo $str;
        }
    }
    ?>
      

  7.   

    刚才又echo $wyx_name;
    echo $wyx_pass;结果显示的用户名和我进入phpmyadmin打开用户表里的字段内容相符啊...
      

  8.   

    SQL语句在数据库里测试一下,看能不能成功
      

  9.   

     $sql="select * from wyx_user where wyx_name='$wyx_name'&&wyx_pass='$wyx_pass'";
        $sql=@mysql_query($sql);    mysql_query("set names 'gb2312'"); //要不在这里加上这句
        
        $rs=@mysql_fetch_array($sql);    echo $rs[0]."and",$rs[1];   //echo 一下看看    if($rs)
    {