ทำตามเว็ป PHP MySQL กับ Login Form แล้วติด Error ช่วยแก้หน่อยค่ะ
Error ?
Date :
2011-08-25 13:30:05
By :
webmaster
พอเข้า login นะค่ะ มันติด Error แบบนี้นะค่ะ ช่วยหน่อยนะค่ะ
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\session\chkLogin.php:13) in C:\AppServ\www\session\chkLogin.php on line 28
Date :
2011-08-25 13:36:04
By :
nokzaa
ลองเปลี่ยนเป็น UTF-8 หรือ UTF-8 + BOM หรือ ANSI ครับ
Date :
2011-08-25 13:41:52
By :
webmaster
Code (PHP)
<?
session_start();
mysql_connect("localhost","root","25330147nok");
mysql_select_db("nok");
?>
<!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>
</head>
<body>
<?
$txtUsername=trim($_POST['txtUsername']);
$txtPassword=trim($_POST['txtPassword']);
$strSQL = "select * from member where Username='$txtUsername' and Password ='$txtPassword'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult) {
echo "Username and Password Incorrect!";
} else {
$_SESSION["UserID"] = $objResult["UserID"];
$_SESSION["Status"] = $objResult["Status"];
session_write_close();
if($objResult["Status"] == "ADMIN") {
header ("http://localhost/session/admin.php");
}else {
header ("http://localhost/session/userr.php");
}
}
mysql_close();
?>
</body>
</html>
มันไม่มีให้เลือกนะค่ะ แล้วมีทางอื่นไหมค่ะ ที่จะได้ค่า admin หรือ user ที่ login เข้าไปแล้วส่งค่าไปหน้าที่ใช้เซ็กนะค่ะ
ประวัติการแก้ไข 2011-08-25 13:50:29
Date :
2011-08-25 13:46:43
By :
nokzaa
ใช้ Edit Plus ครับ
Date :
2011-08-25 13:51:13
By :
webmaster
ไม่เคยใช้ edit plus เลยค่ะ ใช้แต่ดรีมตลอด ถ้าเปลี่ยนใหม่กลัวไม่ทันนะค่ะ เหลืออีกแค่เดือนเดียวนะค่ะ
Date :
2011-08-25 14:08:16
By :
nokzaa
Modify => Page Properties=>title Encoding=>Encodingเปลี่ยนเป็น unicode (UTF-8)
Date :
2011-08-25 14:18:11
By :
webmaster
เหมือนเดิมค่ะ มีการส่งด้วยวิธีอื่นไหมค่ะ
header("admin.php");
}else {
header("userr.php");
ถ้าเป็น echo มันออกถูกต้องค่ะ แต่ไม่สามารถ link ไปหาหน้าที่ใช้เซ้กค่าได้
พี่มีตัวอย่างระบบบางไหมค่ะ เพื่อจาเอามาประยุกต์ใช้นะค่ะ ^^
ประวัติการแก้ไข 2011-08-25 15:03:49
Date :
2011-08-25 14:49:14
By :
nokzaa
ก็ตัวนั้นแหละตัวอย่างครับ หรือไม่ลองแบบนี้ดูครับ
Code (PHP)
<?ob_start();
session_start();
mysql_connect("localhost","root","25330147nok");
mysql_select_db("nok");
?>
Date :
2011-08-25 15:18:16
By :
webmaster
Load balance : Server 05