我已經搜索了很多通網絡,但沒有解決的解決了我problem..and我仍然得到這個錯誤
警告:在session_start()[function.session啓動]:無法發送會話cookie - 頭已經發出(輸出開始 這裏是我的代碼如何刪除無法發送會話cookie錯誤完全
<?php
ob_start();
session_start();
$myusername = $_POST['username'];
$mypassword = $_POST['password'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$mypassword = md5($mypassword);
$con = mysql_connect("localhost", "root", "");
if(!$con) {
die('Error connecting to server :'.mysql_error());
}
mysql_select_db("user_login",$con);
$result = mysql_query("SELECT username, password FROM user_info WHERE username='$myusername' && password='$mypassword'");
if(!mysql_fetch_array($result, MYSQL_ASSOC)) {
//echo "<b><p>Wrong username or password.</p></b>";
//echo "<br /><a href='http://localhost/simic/option.php?page=login'>
Go back to login page </a>";
header('Location: option.php?page=attempt_to_login');
} else {
$_SESSION['access'] = 1;
$_SESSION['user'] = $_POST[username];
header('Location: option.php?page=online');
}
mysql_close($con);
ob_flush();
?>
那麼,如何解決這個問題,請???任何幫助
你在文件前有一些文字[空白] – DevZer0
'session_start();'應該是第一個啓動腳本,將它移動到01行 – jycr753
@ jycr753 session_start()無關緊要,它可以在第2行 –