将登录用户重定向到特定的PHP页面

时间:2015-05-04 11:08:08

标签: php redirect

我的网站上有FreeHelpDesk.org,我想将登录用户重定向到fhd_dashboard.phpfhd_login.php。默认情况下,它会重定向到我不想要的index.php,因为我对index.php进行了很多更改,这是一个登录页面。无论如何拒绝登录用户访问index.php

2 个答案:

答案 0 :(得分:0)

在index.php页面中,一旦调用了会话等,并且您有办法判断用户是否已登录,您可以添加以下内容:



// Assuming that here, if the user is logged in, then the 
// $logged_in variable is set to true/1 - edit this accordingly
// If the user is logged in
if($logged_in){
    
    //Redirect the user to the page that you want
    header("Location: fhd_dashboard.php");
}




这会将用户重定向到fhd_dashboard.php而不是index.php。

答案 1 :(得分:0)

您需要在Index.php文件中添加此代码

$UserIsLogin;
if(//check user is login){
$UserIsLogin=true;
}else{
$UserIsLogin=false;
}
if($UserIsLogin==true) {
 header('Location: fhd_dashbord.php');
} else {
    header('Location: fhd_login.php');
}

Q1.您将信息存储在$ _Session中?