0

这是我的代码:是否有可能使

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中的新手...

4

1 回答 1

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成员。

于 2013-02-01T18:56:23.840 回答