-1

使用 xamp 服务器运行项目时出现错误。错误是 Notice: Undefined index: access in C:\xampp\htdocs\Course\includes\header.php on line 8 。我在此处包含 header.php 文件,请帮助我。

<?php
If (!isset($user) && !stristr($_SERVER['REQUEST_URI'],'login.php')  
                && !stristr($_SERVER['REQUEST_URI'],'add_user.php')
                 && !stristr($_SERVER['REQUEST_URI'],'forgotten_password.php')) {   
    $user = $_SESSION['learner'];
    $user->set_profile();
}
If ($_GET['access'] && !stristr($_SERVER['REQUEST_URI'],'login.php')) {
tep_set_accessibility($user->id,$_GET['access']);
    $user = $_SESSION['learner'];
    $user->set_profile();
}
?>
4

2 回答 2

3

您需要检查 $_GET['access'] 是否已设置:

if (isset($_GET['access'])) {

}
于 2013-07-24T12:13:06.183 回答
0

你没有access钥匙在你的$_GET

要么传递值,要么在使用之前检查它

if (isset($_GET['access'])) {
   if ($_GET['access'] && !stristr($_SERVER['REQUEST_URI'],'login.php')) {
   tep_set_accessibility($user->id,$_GET['access']);
    $user = $_SESSION['learner'];
    $user->set_profile();
  }
}
于 2013-07-24T12:14:51.443 回答