2.5.9 พี่อ่า หนูลง Appserv2.5.9 แล้วแต่พอรัน Code กลับเจอ Error แบบนี้ทามไงดีค่ะ Warning: Cannot modify header ination - headers already sent by
ให้เอาบรรทัด session_start(); ไปไว้บรรทัดแรกสุดเลยครับ
Date :
2010-02-16 10:25:25
By :
deawx
พี่หนูไว้บรรทัดรองจากtitleแล้วนะแต่ก้อเหมือนเดิมอ่า
แล้วที่นี้ลองเปลี่ยน header ("Location:admin/index_admin.php");
เป็น
<script language="javascript">
location.href="admin/index_admin.php";
</script>
ก้อค่าsessionไม่ส่งไปอีกหน้านึงอะ
Date :
2010-02-16 10:32:55
By :
LuckyStar
มันมี output ไปก่อน ส่วนหัวคับ ดังนั้นลองใส่ ob_start(); ไว้บรรทัดแรกสุดครับ
Date :
2010-02-16 11:24:56
By :
pjgunner
พี่าอ่าหนูลองแล้วอะไม่ได้อะ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<?
ob_start();
@session_start();
include('config.inc.php');
?>
<SCRIPT LANGUAGE='JavaScript'>
function backpage(){
var t=setTimeout("history.back()",5000);
}
</SCRIPT>
</head>
<body>
<?
$username=$_POST["Username"];
$pass=$_POST["Password"];
$password=md5($pass);
if ($username=="" or $password=="") {
echo "<h3> <center>ERROR : You can't login.Please check your data again.</center> </h3>";
echo "<center><img src='images/loading45.gif' /></center>";
echo"<center><a href='login_admin.php'>click here.If your browser do not work.</a></center>";
echo "<SCRIPT LANGUAGE='JavaScript'>";
echo "backpage();";
echo "</SCRIPT>";
}else{
$sql=mysql_query("select * from admin where username='$username' and password='$password'");
$num=mysql_num_rows($sql);
if($num==0){
echo "<h3> <center>ERROR : Username and password incorrect. Please login agine. </center></h3>";
echo " <center><img src='images/loading7.gif' /> </center>";
echo"<center><a href='login_admin.php'>click here.If your browser do not work.</a></center>";
echo "<SCRIPT LANGUAGE='JavaScript'>";
echo "backpage();";
echo "</SCRIPT>";
}else{
while($ob=mysql_fetch_array($sql)){
$_SESSION[ID_Ad]=$ob[0];
$_SESSION[User_Ad]=$ob[1];
}
header ("Location:admin/index_admin.php");
}
mysql_close();
}
?>
</body>
</html>
Date :
2010-02-16 12:10:05
By :
LuckyStar
ช่วยด้วยค่ะ
Date :
2010-02-16 12:10:24
By :
LuckyStar
บรรทัดแรกก่อนมี output ครับ แรกสุด
Date :
2010-02-16 12:15:54
By :
pjgunner
แบบนี้นะครับ
ob_start();
session_start();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<?
include('config.inc.php');
?>
<SCRIPT LANGUAGE='JavaScript'>
function backpage(){
var t=setTimeout("history.back()",5000);
}
</SCRIPT>
</head>
<body>
<?
$username=$_POST["Username"];
$pass=$_POST["Password"];
$password=md5($pass);
if ($username=="" or $password=="") {
echo "<h3> <center>ERROR : You can't login.Please check your data again.</center> </h3>";
echo "<center><img src='images/loading45.gif' /></center>";
echo"<center><a href='login_admin.php'>click here.If your browser do not work.</a></center>";
echo "<SCRIPT LANGUAGE='JavaScript'>";
echo "backpage();";
echo "</SCRIPT>";
}else{
$sql=mysql_query("select * from admin where username='$username' and password='$password'");
$num=mysql_num_rows($sql);
if($num==0){
echo "<h3> <center>ERROR : Username and password incorrect. Please login agine. </center></h3>";
echo " <center><img src='images/loading7.gif' /> </center>";
echo"<center><a href='login_admin.php'>click here.If your browser do not work.</a></center>";
echo "<SCRIPT LANGUAGE='JavaScript'>";
echo "backpage();";
echo "</SCRIPT>";
}else{
while($ob=mysql_fetch_array($sql)){
$_SESSION[ID_Ad]=$ob[0];
$_SESSION[User_Ad]=$ob[1];
}
header ("Location:admin/index_admin.php");
}
mysql_close();
}
?>
</body>
</html>
Date :
2010-02-16 12:31:18
By :
Dragons_first
เย้ๆได้แล้วขอบคุนมากนะค่ะ
Date :
2010-02-16 13:16:45
By :
LuckyStar
Load balance : Server 00