我有一个PHP脚本,应该让用户查看基于user_level的页面。如果用户级别设置为1 ..允许用户查看页面。如果没有,然后重定向到index.php ..由于某种原因,它不工作。它给了我一个信息,“你不能访问这个页面”。无论是谁登录,管理员或普通用户,它都会给我提供该信息。有任何想法吗?管理员权限在php
<?php
include 'init.php';
include('core/init.inc.php');
var_dump($_SESSION)
if(!logged_in()){
header('Location: index.php');
exit();
}
if(!isset($_SESSION['user_level'])) {
echo 'You are not allowed to access this page. Click <a href="index.php">here</a> to go back to the home page';
exit();
}elseif(1 == (int)$_SESSION['user_level']){
header('Location: create_album.php');
exit;
}
include 'template/header.php';
?>
@ TechGuy24试试我张贴,它检查isset'user_level'第一代码。 – xdazz
它仍然显示你不允许的消息,无论用户级别 – WebDeVGuy24
@ TechGuy24请执行'var_dump($ _ SESSION)'并首先检查内容。 – xdazz