<?php
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];
if ($user_login=="" or $pass_login=="") {
echo "<h3>ERROR : กรุณากรอกข้อมูลให้ครบนะครับ<h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login' and password='$pass_login'";
$result=mysql_db_query($dbname,$sql);
$num=mysql_num_rows($result);
mysql_close();
if($num<=0) {
echo "<h3>ERROR : Username หรือ Password ไม่ถูกต้อง</h3>";
} else {
session_start();
$_SESSION[sess_userid]=session_id();
$_SESSION[sess_username]=$user_login;
header("Location: main.php");
}
?>
ผลออกมาเป็นยังงี้ครับ
Code
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\AppServ\www\phpweb\db_member\chkmember.php:9) in C:\AppServ\www\phpweb\db_member\chkmember.php on line 25
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\phpweb\db_member\chkmember.php:9) in C:\AppServ\www\phpweb\db_member\chkmember.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\phpweb\db_member\chkmember.php:9) in C:\AppServ\www\phpweb\db_member\chkmember.php on line 28
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];
if ($user_login=="" or $pass_login=="") {
echo "<h3>ERROR : กรุณากรอกข้อมูลให้ครบนะครับ<h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login' and password='$pass_login'";
$result=mysql_db_query($dbname,$sql);
$num=mysql_num_rows($result);
mysql_close();
if($num<=0) {
echo "<h3>ERROR : Username หรือ Password ไม่ถูกต้อง</h3>";
} else {
$_SESSION[sess_userid]=session_id();
$_SESSION[sess_username]=$user_login;
header("Location: main.php");
}
?>
</body>
</html>
แล้วเป็นแบบนี้ครับ
Code
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\phpweb\db_member\chkmember.php:9) in C:\AppServ\www\phpweb\db_member\chkmember.php on line 27