这是我的代码:是否可以制作
if(isset($_GET['home'])){
if($_SESSION['valid_user']==null){
$_SESSION['pages']=0;//this is when user is not login or visitor
}else{
if($_SESSION['valid_admin']==1){
$_SESSION['pages']=1;//this is when user is login as admin
}else{
$_SESSION['pages']=2;//this is where user is login
}
}
}
当我像这样编写代码时。
if(isset($_GET['home'])){
if($_SESSION['valid_user']==null){
$_SESSION['pages']=0;//this is when user is not login or visitor
}else{
if($_SESSION['valid_admin']==null){
$_SESSION['pages']=0;//this is when user is login as admin
}else{
$_SESSION['pages']=2;//this is where user is login
}
}
}
我应该把代码放在哪里如果valid_admin或admin_user是登录我为我的主页创建了3个不同的页面... 1 =对于用户1 =对于管理员而1 =对于访问者抱歉我的坏英语我只是和新手在php ...
答案 0 :(得分:0)
我会选择类似的东西:
if(isset($_GET['home'])){
if(isset($_SESSION['valid_user'])) {
$_SESSION['pages']=0;//this is when user is not login
} else {
if(isset($_SESSION['valid_admin'])) {
$_SESSION['pages']=1;//this is when user is login as admin
} else {
$_SESSION['pages']=2;//this is where user is login or Visitor
}
}
}
在这种情况下,您只需设置相应的$_SESSION
成员。