在頁面加載時獲取以下警告消息。我不明白那是什麼?發生PHP會話問題
警告:session_start()[function.session-start]:無法發送會話緩存限制器 - 已在/ home/heimann中發送的頭文件(輸出開始於/home/heimann/public_html/admin/login.php:9) /public_html/admin/login.php on line 47
警告:無法修改標頭信息 -/home/heimann中已經由(home /heimann/public_html/admin/login.php:9開始處的輸出)發送的標頭信息/public_html/admin/login.php線路52上
PHP代碼
//line 9 <?php
$admin = 'http://'. $_SERVER['HTTP_HOST'] . '/admin/';
$db = new MySQLi('localhost', 'heimann_admin', '0579ural', 'heimann_content') or die($db->error);
$db->set_charset('utf8');
$username=$db->escape_string($_POST['username']);
$password=$db->escape_string($_POST['password']);
$submit=$db->escape_string($_POST['submit']);
if($username && $password && $submit=='Giriş'){
$result=$db->query("SELECT id, username, password FROM users WHERE username='$username' AND password='$password'");
$count=$result->num_rows;
if($count>0)
{
while($row=$result->fetch_object()){
$dbusername=$row->username;
$dbpassword=$row->password;
$dbuserid=$row->id;
}
if($username==$dbusername && $password==$dbpassword){
//line 47 session_start();
$_SESSION['username']=$dbusername;
$_SESSION['userid']=$dbuserid;
//line 52 header('location:'.$admin);
}
else message("Şifrə səhvdir");
}
else {message("Bazada belə login və şifrə kombinasiyası yoxdur");}
}
else {message("Giriş parametrlərindən biri daxil edilməyib");}
?>
<?
function message($text){
global $admin;
echo '<div class="message">'.$text. '</br><a href="'.$admin.'">Geri</a></div>';
}
?>
你的php代碼從第9行開始,你的會話在#47。我會將Session_start置於頂部,並且頭部(位置)應該在任何輸出發送 – Lixas