无法使用管理员登录?

时间:2013-11-02 06:51:41

标签: php

如果我的代码或我的数据库有什么问题?

我的代码

    if(isset($login)){
        if($sbg=='administrator'){
            $login = mysql_query("SELECT * FROM administrator WHERE email='$email' AND password='$pass'");
            $rows= mysql_num_rows($login);
            if($rows==0){
                $data = mysql_fetch_array($login);
                $_SESSION['login']      = true;
                $_SESSION['nama']       = $data['nama'];
                $_SESSION['email']      = $data['email'];
                $_SESSION['password']          = $data['password'];
            }else{

3 个答案:

答案 0 :(得分:2)

看起来你必须改变

if($rows==0)

if($rows>0)

答案 1 :(得分:0)

你把代码放错了。

if($rows!=0){
                $data = mysql_fetch_array($login);
                $_SESSION['login']      = true;
                $_SESSION['nama']       = $data['nama'];
                $_SESSION['email']      = $data['email'];
                $_SESSION['password']          = $data['password'];
            }else{

答案 2 :(得分:0)

if(isset($login)){
        if($sbg=='administrator'){
            $login = mysql_query("SELECT * FROM administrator WHERE email='$email' AND password='$pass'");
            $rows= mysql_num_rows($login);

            if($rows>0){
                $data = mysql_fetch_assoc($login);
                session_start();
                $_SESSION['login']      = true;
                $_SESSION['nama']       = $data['nama'];
                $_SESSION['email']      = $data['email'];
                $_SESSION['password']          = $data['password'];
            }else{
}

你可以只回显$行,知道如果$ rows显示0或者没有结果,请检查你的mysql查询。