我想让某个页面只能对某个数据库组可见。我的 SQL 表设置为:
表:DD_users 列:id | 集团 | 用户名 | 释义 | 公会 | 水平 | 盐
这是我尝试使用的代码:
// First we execute our common code to connection to the database and start the session
require("common.php");
// At the top of the page we check to see whether the user is logged in or not
if(empty($_SESSION['user']))
{
// If they are not, we redirect them to the login page.
header("Location: /DD/index.php");
// Remember that this die statement is absolutely critical. Without it,
// people can view your members-only content without logging in.
die("Redirecting to /DD/index.php");
}
if($_SESSION['user']['group'] == '0')
{
// Destroy the session to make them log in again.
unset($_SESSION['user']);
// If they are not, we redirect them to the login page.
header("Location: /DD/index.php");
// Remember that this die statement is absolutely critical. Without it,
// people can view your members-only content without logging in.
die("Redirecting to /DD/index.php");
}
// Everything below this point in the file is secured by the login system
当我尝试这个时,当我只希望组 1 和 2 访问该页面时,将允许任何用户组(0、1 和 2)访问该页面。