<body>
<?php
session_start();
$host = "127.0.0.1";
$user = "root";
$passwd = "1234";
$dbname = "register";
mysql_connect($host,$user,$passwd) or die ("ติดต่อฐานข้อมูลไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
$sql = "select * from userinfo where logname ='$logname' and pw ='$pw' ";
$dbquery = mysql_db_query($dbname,$sql);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{ if($check== "on")
{
setcookie("logname",$logname,time()+3600*24*356);
setcookie("pw",$pass,time()+3600*24*356);
header("location:www.google.co.th");
} else {
header("location:www.google.co.th");
}
}else {
$code_error="ข้อมูลไม่ถูกต้องกรุณา login ใหม่ ";
session_register("code_error");
header("location:logintest.php");
};
?>
</body>
</html>
พอลองรันดู ขึ้นงี้อะ
Code
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\AppServ\www\projectphp\checkuser.php:9) in C:\AppServ\www\projectphp\checkuser.php on line 10
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\projectphp\checkuser.php:9) in C:\AppServ\www\projectphp\checkuser.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\projectphp\checkuser.php:9) in C:\AppServ\www\projectphp\checkuser.php on line 32