cookie + mysql [PHP]


<?
ob_start();
require_once "config.php";
//เริ่มติดต่อฐานข้อมูล
mysql_connect($host, $db_username, $db_password) or die("ติดต่อฐานข้อมูลไม่ได้");
// เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
// คำสั่ง SQL และสั่งให้ทำงาน
$sql = "select * from tb_member where user_log='$username_log' and pass_log='$password_log'"; //เช็คค่าข้อมูลที่ส่งมาจากฟอร์ม
$dbquery = mysql_db_query($dbname, $sql);
// หาจำนวนเรกคอร์ดข้อมูล
$num_rows = mysql_num_rows($dbquery);
if($num_rows == 1) {
if($chk == "on") { // ถ้าติ๊กถูก Login ตลอดไป ให้ทำการสร้าง cookie
setcookie("username_log",$username_log,time()+3600*24*356);
setcookie("password_log",$password_log,time()+3600*24*356);
header("location:hxxp://vvv.webthaidd.com"); //ไปไปตามหน้าที่คุณต้องการ
} else {
header("location:hxxp://vvv.webthaidd.com"); //ไปไปตามหน้าที่คุณต้องการ
}
} else {
header("location: form_login.php"); //ไม่ถูกต้องให้กับไปหน้าเดิม
}
?>

#webthaidd