|
 |
|
รบกวนขอคำแนะนำเรื่อง การตรวจสอบการล็อกอินจาก 2 ตารางหน่อยคับ |
|
 |
|
|
 |
 |
|
โค๊ดเดิมที่ยังไม่แยกตารางคับ
Code (PHP)
<?
session_start(); //เปิด seesion เพื่อทำงาน
$username=$_POST[username]; //ประกาศซตัวแปรชื่อ username โดยการรับค่ามาจากกล่อง username ที่หน้า Login
$password=$_POST[password]; //ประกาศซตัวแปรชื่อ password โดยการรับค่ามาจากกล่อง password ที่หน้า Login
if($username=="") {
echo “ท่านยังไม่ได้กรอกชื่อผู้ใช้ครับ”;
}else if($password=="") {
echo “ท่านยังไม่ได้กรอกรหัสผ่านครับ”;
} else {
//include("include/include.client.php");
include("include/include.default.php");
$check_log =mysql_query("select * from people_tb where username ='$username' and password ='$password'")or die(mysql_error);
$num=mysql_num_rows($check_log);
if($num <=0) { //ถ้าหากค่าที่ได้ออกมามีค่าต่ำกว่า 1
echo "Username หรือ Password อาจจะผิดกรุณา Login ใหม่อีกครั้ง <br /><a href='login.php'>ย้อนกลับไปแก้ไข</a>";
}else{
while($data = mysql_fetch_array($check_log)){ //ถ้าค่ามีมากกว่า 0 ขึ้นไป ให้ดึงข้อมูลออกมาทั้งหมด
if($data['status_user']==ผู้ดูแลระบบ){
echo"ท่านเข้าใช้งานระบบในสถานะ: ผู้ดูแลระบบ";
//ตรวจสอบสถานะของผู้ใช้ว่าเป็น Admin
$_SESSION['id']=session_id(); //สร้าง session สำหรับเก็บค่า ID
$_SESSION['username']=$username; //สร้าง session สำหรับเก็บค่า Username
$_SESSION['status_user']="ผู้ดูแลระบบ";
$_SESSION['password']=$password; //สร้าง session สำหรับเก็บค่า สถานะความเป็น Admin
echo "<meta http-equiv='refresh' content='1;URL=index.php'>";
}elseif($data['status_user']==บุคคลทั่วไป){
echo"ท่านเข้าใช้งานระบบในสถานะ: บุคคลทั่วไป";
//ตรวจสอบสถานะของผู้ใช้งานว่าเป็น user
$_SESSION['id']=session_id(); // สร้าง session สำหรับให้ User นำไปใช้งาน
$_SESSION['username']=$username;
$_SESSION['status_user']="บุคคลทั่วไป";
$_SESSION['password']=$password;
echo "<meta http-equiv='refresh' content='1;URL=index.php'>"; //ส่งค่าจากหน้านี้ไปหน้า index_user.php
exit();
}
exit();
}
exit();
}
exit();
}
?>
|
 |
 |
 |
 |
Date :
2013-09-26 04:54:14 |
By :
djrocky |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตารางคับ แนะนำด้วยคับ 
|
 |
 |
 |
 |
Date :
2013-09-26 09:58:33 |
By :
djrocky |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|