doucong1992 2013-02-01 18:52
浏览 26

关于我的页面验证或验证

this is my code: is it possible to make

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
    }
}
}

when i make my code like this.

 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
    }
}
}

where should i put the code for if the valid_admin or admin_user is login i created 3 different pages for my home page.. 1=for user 1=for admin and 1=for visitor sorry for my bad english im am just and newbie in php...

  • 写回答

1条回答 默认 最新

  • douyi4297 2013-02-01 18:56
    关注

    I would go with something like:

    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
        }
      }
    }
    

    and in that case you only set the according $_SESSION member.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法