-1

助けてください。このコードの問題点は何ですか。別のユーザー レベルでログインを作成しようとしていますが、管理者または他のユーザーとしてログインしようとすると、要求ページに移動しませんでした。

ここにコードがあります

<?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);
}

?>

4

1 に答える 1

0

ヘッダー関数には、相対ファイル システム パスではなく、完全修飾 URL を含める必要があります。

header('Location: http://www.example.com/views/admin/dashboard.php');
于 2013-02-10T19:22:09.813 に答える