-3

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

我的代码

    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{
4

3 回答 3

2

看起来你必须改变

if($rows==0)

if($rows>0)
于 2013-11-02T06:53:44.613 回答
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{
于 2013-11-02T06:54:07.397 回答
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 或什么都没有,您可以回显 $rows 以了解是否有结果,请检查您的 mysql 查询。

于 2013-11-02T09:14:41.623 回答