使用不同用户级别的PHP登录

使用不同用户级别的PHP登录,php,sql,Php,Sql,请帮忙。这个代码有什么问题。我正在尝试创建一个不同用户级别的登录,但是当我尝试以管理员或其他用户身份登录时,它没有指向请求页面 这是密码 <?php ...//the problem goes here, it didn't direct to the request page if(empty($error)){//if the array is empty , it means no error found $query_check = "SELECT * FROM user

请帮忙。这个代码有什么问题。我正在尝试创建一个不同用户级别的登录,但是当我尝试以管理员或其他用户身份登录时,它没有指向请求页面

这是密码

<?php
...//the problem goes here, it didn't direct to the request page

if(empty($error)){//if the array is empty , it means no error found
    $query_check = "SELECT * FROM users WHERE (email = '$email' AND password= '$password') AND activation IS NULL";
    $result = mysqli_query($db_conn, $query_check);
    if(!$query_check){
    echo "Query Failed";        
    }
    if(@mysqli_num_rows($result)==1){//if match
        $_SESSION = mysqli_fetch_array($result,MYSQLI_ASSOC); //Assign the result of this query to SESSION Global Variable
        $row = mysqli_fetch_array ($result, MYSQLI_ASSOC);
            if($row['role_type']=='admin'){
                header("Location:../views/admin/dashboard.php");
                exit;
            }
            if($row['role_type']=='staff'){
                header("Location:../views/staff/dashboard.php");
            }
            if($row['role_type']=='patient'){
                header("Location: ../views/dafault/home.php");
            }
    }else{
        $msg_error = "Either Your Account is inactive or Email address /Password is Incorrect";
    }
}else{
    echo '<div class="errormsgbox"> <ol>';
    foreach($error as $key => $values){
        echo '  <li>'.$values.'</li>';
    }
    echo '</ol></div>';
}

if(isset($msg_error)){
    echo '<div class="warning">'.$msg_error.' </div>';
    }
mysqli_close($db_conn);
}

头函数应该包含完全限定的url,而不是相对的文件系统路径

header('Location: http://www.example.com/views/admin/dashboard.php');

您应该能够缩小问题的范围,而不必向我们展示您所有的代码抱歉。我试图将页面指向用户页面请求,用于选择不同用户级别的if语句无效。
echo$row['role_type';退出()这是您所期望的吗?我还尝试用else if替换if,但仍然不起作用。我们开始在脚本中放置die(‘消息’),直到您确定它到达/不到达的位置。