|
|
|
ช่วยด้วยครับ ทำหน้าloginแล้ว ไฟล์action มันทำงานได้แต่มันอ่านข้อมูลจากmysqlผิดพลาดอ่ะครับ |
|
|
|
|
|
|
|
ลองใช้ isset ดูดิ
|
|
|
|
|
Date :
2009-06-22 19:17:16 |
By :
nottpoo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไงอ่าครับมันคือ...ผมไม่ค่อยเก่งอ่าผมมือไหม่ พอดีไปเช่าโฮสแล้สลองทำในเครื่องมันก็ได้นะครับ แต่พอขึ้นโฮสมันกลับไม่ได้
|
|
|
|
|
Date :
2009-06-22 19:36:55 |
By :
Sososaity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$conn=mysql_connect("localhost","dbuser","dbpass");
$select_db=mysql_select_db("dbname",$conn);
$username_log=$_POST['username_log'];
$password_log=$_POST['password_log'];
// คำสั่ง SQL และสั่งให้ทำงาน
$sql = "SELECT * FROM users where userid='$username_log' and user_pass='$password_log'"; //เช็คค่าข้อมูลที่ส่งมาจากฟอร์ม
$result= mysql_query($sql);
// หาจำนวนเรกคอร์ดข้อมูล
$num_rows = mysql_num_rows($result);
if($num_rows==1){
$_SESSION['username']=$username_log;
header("location:dindex.php"); //ไปไปตามหน้าที่คุณต้องการ
}else {
$code_error="<BR><FONT COLOR=\"red\">กรุณาปิด Website แล้วเปิดไหม่ด้วยครับ เนื่องจาก User ท่านผิด</FONT>";
session_register("code_error");
header("location:dlogin.php"); //ไม่ถูกต้องให้กับไปหน้าเดิม
}
?>
|
|
|
|
|
Date :
2009-06-23 06:52:26 |
By :
kongoon |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
action.php
$hostname = "localhost"; //ชื่อโฮสต์
$user = ""; //ชื่อผู้ใช้
$password = ""; //รหัสผ่าน
$dbname = ""; //ชื่อฐานข้อมูล
$tblname = ""; //ชื่อตาราง
// เริ่มติดต่อฐานข้อมูล
mysql_connect($hostname, $user, $password) or die("ติดต่อฐานข้อมูลไม่ได้");
// เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
// คำสั่ง SQL และสั่งให้ทำงาน
$sql = "select * from $tblname where userid='$username_log' and user_pass='$password_log'"; //เช็คค่าข้อมูลที่ส่งมาจากฟอร์ม
$dbquery = mysql_db_query($dbname, $sql);
// หาจำนวนเรกคอร์ดข้อมูล
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1){
session_register("username_log");
header("location:dindex.php"); //ไปไปตามหน้าที่คุณต้องการ
}else {
$code_error="<BR><FONT COLOR=\"red\">กรุณาปิด Website แล้วเปิดไหม่ด้วยครับ เนื่องจาก User ท่านผิด</FONT>";
session_register("code_error");
header("location:dlogin.php"); //ไม่ถูกต้องให้กับไปหน้าเดิม
}
?>
คุณยังไม่มี session_start() เท่าที่ดูนะครับ....ไม่รู้ว่าถูกปะลองไปดูนะครับ
|
|
|
|
|
Date :
2009-06-23 14:21:47 |
By :
tuanau |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะลองดูนะครับขอบคุณครับ
|
|
|
|
|
Date :
2009-06-23 17:32:25 |
By :
Sososaity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ของคนที่3อ่ะครับใช้ได้ขอบคุณครับ
|
|
|
|
|
Date :
2009-06-23 18:54:30 |
By :
Sososaity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|