所以,目前,我正在为论坛制作一个mod面板。数据库中有一个名为“版主”的变量。默认值为0,但我希望能够将其设置为“1”,然后人们可以访问页面。我目前正在寻找类似下面的内容:
<?php
include('config.php');
if(isset($_SESSION['moderator']) and $_SESSION['moderator']) {
} else {
header("location:noaccess.php");
}
?>
然而,它不起作用,因为我无法想出一种说法,如果它是1,然后允许访问。这是config.php的强制性。 '*'=删除信息
<?php
/******************************************************
------------------Required Configuration---------------
Please edit the following variables so the forum can
work correctly.
******************************************************/
//We log to the DataBase
mysql_connect('*', '*', '*');
mysql_select_db('forum_database');
//Username of the Administrator
$admin='The_Darthonian'; // For admin forum features
/******************************************************
-----------------Optional Configuration----------------
******************************************************/
//Forum Home Page
$url_home = 'index.php';
//Design Name
$design = 'default';
/******************************************************
----------------------Initialization-------------------
******************************************************/
include('init.php');
?>
由于
答案 0 :(得分:0)
翻转您的逻辑......
<?php
include 'config.php';
if(empty($_SESSION['moderator'])) {
// $_SESSION['moderator'] is not set or 0
header("Location:noaccess.php");
exit;
}
// $_SESSION['moderator'] is set and something other than 0,
// the following page is moderator only...