|
 |
|
รัน session ในส่วน log in ไม่ผ่านคะ รบกวนช่วยดูให้หน่อยคะ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
session_start();
include( "config.inc.php" );
$username = trim($_POST["username"]);
$password = trim($_POST["password"]);
$objConnect = mysql_connect("localhost","root","1208") or die("Error Connect to Database");
$objDB = mysql_select_db("books_ict");
if ($username != "" && $password != "")
{
$password_md5 = md5($password);
$strSQL = "select * from member where username='$username' and password='$password_md5'"; //check value that come from form
$dbquery = mysql_db_query($dbname, $strSQL);
// find the first record
$num_rows = mysql_num_rows($dbquery);
if($num_rows == 1)
{
if($checkbox == "remember")
{ // ถ้าติ๊กถูก Login ตลอดไป ให้ทำการสร้าง cookie
setcookie("username_cookie",$username,time()+3600*24*356);
setcookie("password_cookie",$password_md5,time()+3600*24*356);
$usernamelogin = $username ;
session_register("usernamelogin") ; //ลงทะเบียน session ให้กับเครื่องที่ Login
header(localhost/registration.php); //ไปไปตามหน้าที่คุณต้องการ
}
else
{
$usernamelogin = $username ;
session_register("usernamelogin") ; //ลงทะเบียน session ให้กับเครื่องที่ Login
header(localhost/registration.php); //ไปไปตามหน้าที่คุณต้องการ
}
}
else
{
echo "<meta http-equiv=\"refresh\" content=\"5 ;url=index.php?loginform=show\">" ;
echo "$strSQL";
//echo Message("block", "ไม่สามารถ Login ได้", "Username หรือ Password ไม่ถูกต้องค่ะ<br /><br />กรุณารอสักครู่ ระบบจะพาคุณไปหน้า Login โดยอัตโนมัติ... หรือคลิกปุ่มด้านล่าง", " Login ", "window.location = 'login.php?loginform=show'");//เรียกฟังชั่นกล่องข้อความ
}
}
?>
คือส่วนนี้นะคะ ก๊อปจากที่นี้อีกที แร้วรันไม่ได้ มานไม่เข้า condition
if($num_rows == 1) ไม่ทราบว่า ทำไรผิดป่าวคะ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-09-11 03:51:39 |
By :
aa |
View :
1022 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะระบุชนิดด้วยน่ะครับ $_POST["username"] , $_POST["password"]
ลอง echo $strSQL; แล้วนำค่าที่ได้ไปทดสอบใน phpMyAdmin นะครับ
|
 |
 |
 |
 |
Date :
2009-09-11 06:33:53 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|