我的标头已发送错误。我知道那个错误是什么意思,但我无法解决它..这是我的管理员登录/注销系统..
索引.php
<?php
if(empty($_COOKIE['user'])){
include '/views/admin/login.php';
}
elseif(isset($_COOKIE['user']) || isset($_SESSION['user'])) {
include '/views/admin/admin.php';
}
?>
登录.php
<?php include('/views/admin/header-login.php') ;?>
<div class="wrap">
<div id="content">
<div id="main">
<div class="full_w">
<form method="post">
<h3 id="logins-error"></h3>
<label for="login">Username:</label>
<input id="login" name="login" class="text" />
<label for="pass">Password:</label>
<input id="password" name="password" type="password" class="text" />
<div class="sep"></div>
<button class="login-button" class="ok">Login</button> <a class="button" href="">Forgotten password?</a>
</form>
</div>
<div class="footer">» <a href="/">Avetisyan</a> | Admin Panel</div>
</div>
</div>
</div>
<?php include('/views/admin/footer.php'); ?>
管理员.php
<?php include('/views/admin/header.php') ?>
<div class="wrap">
<div id="header">
<div id="top">
<div class="left">
<p>Welcome, <strong><?php echo $_SESSION['user'] ?></strong> [ <a href="/admin/logout">logout</a> ]</p>
</div>
<div class="right">
<div class="align-right">
<p>Avetisyan | Admin Panel</p>
</div>
</div>
</div>
<div id="nav">
<ul>
<li class="upp"><a href="/admin/main">Main</a></li>
<li class="upp"><a href="/admin/about-us">About Us</a></li>
<li class="upp"><a href="/admin/for-teachers">For Teachers</a></li>
<li class="upp"><a href="/admin/for-pupils">For pupils</a></li>
<li class="upp"><a href="/admin/graduates">Graduates</a></li>
<li class="upp"><a href="/admin/news">News</a></li>
<li class="upp"><a href="/admin/kindergarten">Kindergarten</a></li>
<li class="upp"><a href="/admin/materials">Materials</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="sidebar">
<div class="box">
<div class="h_title">› Pages</div>
<ul id="home">
<li class="b1"><a class="icon view_page" href="/admin/main">Main</a></li>
<li class="b1"><a class="icon view_page" href="/admin/about-us">About Us</a></li>
<li class="b1"><a class="icon view_page" href="/admin/for-teachers">For Teachers</a></li>
<li class="b1"><a class="icon view_page" href="/admin/for-pupils">For Pupils</a></li>
<li class="b1"><a class="icon view_page" href="/admin/graduates">Graduates</a></li>
<li class="b1"><a class="icon view_page" href="/admin/news">News</a></li>
<li class="b1"><a class="icon view_page" href="/admin/kindergarten">Kindergarten</a></li>
<li class="b1"><a class="icon view_page" href="/admin/materials">Materials</a></li>
</ul>
</div>
</div>
<div id="main">
<div class="full_w">
<div class="h_title">Paragraph, headers, lists, notify</div>
<h1>Level 1 header</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumyeirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diamvoluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takim</p>
<h2>Level 2 header</h2>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumyeirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diamvoluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumyeirmod tempor i</p>
<h3>Level 3 header</h3>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumyeirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diamvolupt</p>
<h3>Unordered list</h3>
<ul>
<li>first list item, Lorem ipsum dolor sit amet, consete</li>
<li>second list item, Lorem ipsum dolor sit amet, consete</li>
<li>third list item, Lorem ipsum dolor sit amet, consete</li>
<li>fourth list item, Lorem ipsum dolor sit amet, consete</li>
</ul>
<h3>Ordered list</h3>
<ol>
<li>first list item, Lorem ipsum dolor sit amet, consete</li>
<li>second list item, Lorem ipsum dolor sit amet, consete</li>
<li>third list item, Lorem ipsum dolor sit amet, consete</li>
<li>fourth list item, Lorem ipsum dolor sit amet, consete</li>
</ol>
<div class="n_warning"><p>Attention notification. Lorem ipsum dolor sit amet, consetetur, sed diam nonumyeirmod tempor.</p></div>
<div class="n_ok"><p>Success notification. Lorem ipsum dolor sit amet, consetetur, sed diam nonumyeirmod tempor.</p></div>
<div class="n_error"><p>Error notification. Lorem ipsum dolor sit amet, consetetur, sed diam nonumyeirmod tempor.</p></div>
</div>
<div class="full_w">
<div class="h_title">Add new page - form elements</div>
<form action="" method="post">
<div class="element">
<label for="name">Page title <span class="red">(required)</span></label>
<input id="name" name="name" class="text err" />
</div>
<div class="element">
<label for="category">Category <span class="red">(required)</span></label>
<select name="category" class="err">
<option value="0">-- select category</option>
<option value="1">Category 1</option>
<option value="2">Category 4</option>
<option value="3">Category 3</option>
</select>
</div>
<div class="element">
<label for="comments">Comments</label>
<input type="radio" name="comments" value="on" checked="checked" /> Enabled <input type="radio" name="comments" value="off" /> Disabled
</div>
<div class="element">
<label for="attach">Attachments</label>
<input type="file" name="attach" />
</div>
<div class="element">
<label for="content">Page content <span>(required)</span></label>
<textarea name="content" class="textarea" rows="10"></textarea>
</div>
<div class="entry">
<button type="submit">Preview</button> <button type="submit" class="add">Save page</button> <button class="cancel">Cancel</button>
</div>
</form>
</div>
<div class="full_w">
<div class="h_title">Manage pages - table</div>
<h2>Lorem ipsum dolor sit ame</h2>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumyeirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diamvolupt</p>
<div class="entry">
<div class="sep"></div>
</div>
<table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Title</th>
<th scope="col">Author</th>
<th scope="col">Date</th>
<th scope="col">Category</th>
<th scope="col" style="width: 65px;">Modify</th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-center">2</td>
<td>Home</td>
<td>Paweł B.</td>
<td>22-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<tr>
<td class="align-center">3</td>
<td>Our offer</td>
<td>Paweł B.</td>
<td>22-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<tr>
<td class="align-center">5</td>
<td>About</td>
<td>Admin</td>
<td>23-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<tr>
<td class="align-center">12</td>
<td>Contact</td>
<td>Admin</td>
<td>25-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<tr>
<td class="align-center">114</td>
<td>Portfolio</td>
<td>Paweł B.</td>
<td>22-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<tr>
<td class="align-center">116</td>
<td>Clients</td>
<td>Admin</td>
<td>23-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<tr>
<td class="align-center">131</td>
<td>Customer reviews</td>
<td>Admin</td>
<td>25-03-2012</td>
<td>-</td>
<td>
<a href="#" class="table-icon edit" title="Edit"></a>
<a href="#" class="table-icon archive" title="Archive"></a>
<a href="#" class="table-icon delete" title="Delete"></a>
</td>
</tr>
</tbody>
</table>
<div class="entry">
<div class="pagination">
<span>« First</span>
<span class="active">1</span>
<a href="">2</a>
<a href="">3</a>
<a href="">4</a>
<span>...</span>
<a href="">23</a>
<a href="">24</a>
<a href="">Last »</a>
</div>
<div class="sep"></div>
<a class="button add" href="">Add new page</a> <a class="button" href="">Categories</a>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div class="left">
<p><a href="http://webex.am">Webex Technologies LLC</a> | Admin Panel: <a href="/">Avetisyan</a></p>
</div>
<div class="right">
</div>
</div>
</div>
<?php include('/views/admin/footer.php') ?>
当用户填写字段并提交时,它会转到 validate.php
验证.php
<?php
$user = mysql_real_escape_string($_POST['login']);
$password = mysql_real_escape_string(sha1($_POST['password']));
$query = mysql_query("SELECT * FROM `users` WHERE name = '$user' AND pass = '$password' AND privileges = 'superuser'");
$num_rows = mysql_num_rows($query);
if ($num_rows == '0') {
echo "error";
}
else if($num_rows == '1') {
$expire = time()+3600;
setcookie("user","$user",$expire);
$_SESSION['user'] = $user;
include '/views/admin/admin.php';
}
现在当他登录时,它包括 admin.php 并且在 admin.php 中是注销的链接,它转到 logout.php
注销.php
<?php
session_destroy();
$expire = time()-4000;
setcookie("user","$user",$expire);
?>
在这里它说
警告:无法修改标头信息 - 标头已由 Z:\home\test1.ru\www\views\ 中的(输出开始于 Z:\home\test1.ru\www\views\admin\logout.php:1)发送第 4 行的 admin\logout.php
请给我解决方案,固定代码,以便我可以继续我的工作:)
谢谢!!
编辑
头文件.php
头文件.php
<!DOCTYPE html>
<html>
<head>
<title>Nor-Avetisyan Admin</title>
<link rel="stylesheet" href="<?php echo URL ?>views/admin/css/navi.css">
<link rel="stylesheet" href="<?php echo URL ?>views/admin/css/style.css">
<script src="<?php echo URL ?>views/js/jquery-2.0.1.min.js"></script>
</head>
<body>