Possible Duplicate:
Headers already sent in phpPHP錯誤「無法發送會話緩存限制器 - 已經發送了頭......」
我收到以下錯誤:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/t/a/t/brians/html/about.php:9) in /home/content/t/a/t/brians/html/includes/sidebar.php on line 2
在在about.php我有以下的代碼來檢索該文件的sidebar.php:
<?php include('includes/sidebar.php'); ?>
sidebar.php的,我有以下代碼:
<?php
session_start();
$data=array("user1"=>array("url"=>"file1.php","password"=>"pass1"),
"user2"=>array("url"=>"file2.php","password"=>"pass2"));
if(isset($_POST['username']) && isset($_POST['password'])) {
if($data[$_POST['username']]['password'] == $_POST['password']) {
$_SESSION['username'] = $_POST['username'] . " " . $_POST['password'];
header('Location: ' . $data[$_POST['username']]['url']);
} else {
login('The username or password is incorrect. <br />');
}
} else {
login();
}
?>
<?php
function login($response='This is the default message, if there is none provided') {
?>
<img src="../images/clientlogin_header.png" alt="Client Login"></img>
<p>
<div id="login-area">
<form action="" method="post">
<label for="username">username</label>
<input type="text" name="username" />
<label for="password">password</label>
<input type="password" name="password" /><br />
<input type="submit" name="Login" value="Login" class="submit-button" />
</form>
<div style="clear: both;"></div>
</div>
</p>
<?php } ?>
我不能完全解決這個錯誤。任何人都可以給我建議嗎?
請搜索棧溢出該錯誤信息 - 它被問了已經超過5000次了:) http://stackoverflow.com/search?q=+Cannot+send+session+cache+limiter+-+headers+already+sent –