我是PHP编程的新手。我尝试了很多解决方案,但它仍然无法正常工作。 还混淆了如何根据级别检查用户角色。有人可以帮我解决这个问题。
当我运行此代码时,它会出现“注意:未定义的索引:第122行的C:\ xampp \ htdocs \ HTMb \ admin \ headerTESTLevel.php”。
这是我的代码。
headerTESTLevel.php
<?php include 'config.php' ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Record Management System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
<meta name="author" content="Muhammad Usman">
<!-- The styles -->
<link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
<link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
<link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
<link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
<link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
<link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
<link href='css/elfinder.theme.css' rel='stylesheet'>
<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
<link href='css/uploadify.css' rel='stylesheet'>
<link href='css/animate.min.css' rel='stylesheet'>
<!-- jQuery -->
<script src="bower_components/jquery/jquery.min.js"></script>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
<?php require ('include/database.php'); ?>
<?php require ('session.php'); ?>
<?php if (!isset($no_visible_elements) || !$no_visible_elements) { ?>
<!-- topbar starts -->
<div class="navbar navbar-default" role="navigation">
<div class="navbar-inner">
<button type="button" class="navbar-toggle pull-left animated flip">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="home.php"> <img alt="Charisma Logo" src="img/logo20.png" class="hidden-xs"/>
<span>ICT MS</span></a>
<!-- user dropdown starts -->
<div class="btn-group pull-right">
<?php
include('include/database.php');
$user_query=mysql_query("select * from user where user_id='$id_session'")or die(mysql_error());
$row=mysql_fetch_array($user_query); {
?>
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-user"></i><span class="hidden-sm hidden-xs"> <?php echo $row['nama']; ?></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!---<li><a href="#">Profile</a></li>
<li class="divider"></li>-->
<li><a href="logout.php"><i class="glyphicon glyphicon-off"></i> Logout</a></li>
</ul>
</div>
<?php } ?> <!-- user dropdown ends -->
<div class="btn-group pull-right theme-container animated tada">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-tint"></i><span
class="hidden-sm hidden-xs"> Change Theme / Skin</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="themes">
<li><a data-value="classic" href="#"><i class="whitespace"></i> Classic</a></li>
<li><a data-value="cerulean" href="#"><i class="whitespace"></i> Cerulean</a></li>
<li><a data-value="cyborg" href="#"><i class="whitespace"></i> Cyborg</a></li>
<li><a data-value="simplex" href="#"><i class="whitespace"></i> Simplex</a></li>
<li><a data-value="darkly" href="#"><i class="whitespace"></i> Darkly</a></li>
<li><a data-value="lumen" href="#"><i class="whitespace"></i> Lumen</a></li>
<li><a data-value="slate" href="#"><i class="whitespace"></i> Slate</a></li>
<li><a data-value="spacelab" href="#"><i class="whitespace"></i> Spacelab</a></li>
<li><a data-value="united" href="#"><i class="whitespace"></i> United</a></li>
</ul>
</div>
</div>
</div>
<!-- topbar ends -->
<?php } ?>
<div class="ch-container">
<div class="row">
<?php if (!isset($no_visible_elements) || !$no_visible_elements) { ?>
<!-- left menu starts -->
<div class="col-sm-2 col-lg-2">
<div class="sidebar-nav">
<div class="nav-canvas">
<div class="nav-sm nav nav-stacked">
</div>
<ul class="nav nav-pills nav-stacked main-menu">
<?php
include "include/database.php";
if($_SESSION['level'] == 'admin')
{
echo' <li class="nav-header">Main</li>
<li><a class="ajax-link" href="home.php"><i class="glyphicon glyphicon-home"></i><span> Home</span></a></li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span>Staff</span></a>
<ul class="nav nav-pills nav-stacked">
<li><a class="ajax-link" href="item.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Data Staf</span></a></li>
<li><a class="ajax-link" href="addStaf.php"><i class="glyphicon glyphicon-chevron-right"></i><span> + Staf Baru</span></a></li>
<li><a class="ajax-link" href="user.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Admin Account</span></a></li>
</ul>
</li>
<li class="accordion">
<a href="unit.php"><i class="glyphicon glyphicon-th-list"></i><span> Unit</span></a>
</li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span> Jawatan</span></a>
</li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span> Contact</span></a>
</li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span>Senarai Kenderaan</span></a>
</li>
';}
?>
</div>
</div>
</div>
<!--/span-->
<!-- left menu ends -->
<!-- <noscript>
<div class="alert alert-block col-md-12">
<h4 class="alert-heading">Warning!</h4>
<p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
enabled to use this site.</p>
</div>
</noscript>-->
<div id="content" class="col-lg-10 col-sm-10">
<!-- content starts -->
<?php } ?>