我嘗試登錄加載頁面,但也有兩個誤區:無法發送會話cookie - 標題已經發出(當在session_start())
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at Z:\home\lab4\www\login.php:18) in Z:\home\lab4\www\login.php on line 19
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at Z:\home\lab4\www\login.php:18) in Z:\home\lab4\www\login.php on line 19
線19 session_start();
。我試圖刪除瀏覽器中的所有cookie,但沒有幫助。有任何想法嗎?
<body>
<?php
session_start();
if(isset($_POST["enter"]))
{
$login = $_POST["login"];
$password = $_POST["password"];
$query = mysql_query("SELECT * FROM users WHERE password = '$password' AND login = '$login'") or die(mysql_error());
$user_data = mysql_fetch_array($query);
if($user_data)
{
$_SESSION["login"] = $user_data["login"];
$_SESSION["loggedin"] = true;
}
else print('<script>alert("Incorrect login or password!")</script>');
}
也許到這裏看看:http://stackoverflow.com/q/15367131/ 3933332 – Rizier123 2014-11-22 12:42:20