请帮忙。这段代码有什么问题。我正在尝试创建具有不同用户级别的登录名,但是当我尝试以管理员或其他用户身份登录时,它没有指向请求页面。
这是代码
<?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);
}
?>