dousou1878 2016-11-27 19:29
浏览 51

使用PHP和权限登录表单

I have a question, I have a database field called "is-admin", and I have a login form, what I want:

For example user have The value "1" in "is-admin" field and clicks on submit button he will enter to "home1.php", but if he has "0" in is-admin he will enter to "home.php".

My question is how to do that using PHP?

  • 写回答

1条回答 默认 最新

  • dronthpi05943 2016-11-27 19:47
    关注

    First fetch a user array based on username eg. "SELECT is-admin FROM users WHERE username = $username"

    then save this value in var e.g. $user_status and create simple if/else statement e.g.

    if($user_status = 1) {
        header("Location: 'home1.php'");
        exit;
    }else {
        header("Location: 'home.php'");
        exit;
    }
    

    when using header() make sure that output buffering is on, otherwise this this particular example won't work.

    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计