แยกสิทธ์การทำงาน admin กับ user [ช่วยหน่อยค่ะ]
login_chk
<?
include('connect_db.php');
include('connect_config.php');
$tbl_userSQL = "select * from tbl_user where usr_username='$usr_username' and usr_password='$usr_password' and usr_cfid='$cf_id' and usr_status";
$tbl_userQUERY = mysql_db_query($dbname, $tbl_userSQL);
$tbl_userNUM = mysql_num_rows($tbl_userQUERY);
$tbl_users == 0;
while($tbl_users < $tbl_userNUM)
{
$tbl_userRS = mysql_fetch_array($tbl_userQUERY);
$usr_id= $tbl_userRS["usr_id"];
$usr_sign= $tbl_userRS["usr_sign"];
$usr_cfid= $tbl_userRS["usr_cfid"];
$usr_name= $tbl_userRS["usr_name"];
$usr_username= $tbl_userRS["usr_username"];
$usr_password= $tbl_userRS["usr_password"];
$usr_email= $tbl_userRS["usr_email"];
$usr_detail= $tbl_userRS["usr_detail"];
$usr_status= $tbl_userRS["usr_status"];
$tbl_users++;
}
if($tbl_userNUM==0) {
echo "<script>alert('ขออภัย..... ไม่พบรหัสผ่านของคุณ กรุณาตรวจสอบอีกครั้ง'); window.history.go(-1);</script>";
exit();
} else {
/*
session_register("usr");
session_register("pss");
session_register("usrname");
session_register("md");
session_register("usrid");
$usr = $usr_username;
$pss = $usr_password;
$usrname = $usr_name;
$usrid = $usr_id;
*/
if($usr_status>2) {
$md = "admin";
echo "<meta http-equiv='refresh' content = '2; URL = index.php?mode=admin'>";
exit();
} else {
$md = "user";
echo "<meta http-equiv='refresh' content = '0; URL = index.php?mode=user'>";
exit();
}
$VT = "insert into tbl_visitor values ('$todays', '$times', '$REMOTE_ADDR', '$cf_id', '$usr_username', '$usr_password', '$usr_name', '$usr_id', '$md', '1')";
mysql_db_query($dbname, $VT);
}
?>
//มันจะขึ้น ('ขออภัย..... ไม่พบรหัสผ่านของคุณ กรุณาตรวจสอบอีกครั้ง')
Tag : - - - -
Date :
11 ม.ค. 2551 01:09:52
By :
u-know
View :
1540
Reply :
2
admin_chk.php
<?
$tbl_userSQL = "select * from tbl_user where usr_username='$usr' and usr_password='$pss' and usr_cfid='$cf_id' and usr_status>0";
$tbl_userQUERY = mysql_db_query($dbname, $tbl_userSQL);
$tbl_userNUM = mysql_num_rows($tbl_userQUERY);
if($tbl_userNUM==0) {
echo "<script>alert('ขออภัย..... ไม่พบรหัสผ่านของคุณ กรุณาตรวจสอบอีกครั้ง'); window.history.go(-1);</script>";
exit();
}
$tbl_users = 0;
while($tbl_users < $tbl_userNUM)
{
$tbl_userRS = mysql_fetch_array($tbl_userQUERY);
// ตรงนี้ใส่ตัวแปรในแต่ละฟิวด์
$usr_id= $tbl_userRS["usr_id"];
$usr_sign= $tbl_userRS["usr_sign"];
$usr_cfid= $tbl_userRS["usr_cfid"];
$usr_name= $tbl_userRS["usr_name"];
$usr_username= $tbl_userRS["usr_username"];
$usr_password= $tbl_userRS["usr_password"];
$usr_email= $tbl_userRS["usr_email"];
$usr_detail= $tbl_userRS["usr_detail"];
$usr_status= $tbl_userRS["usr_status"];
// ส่วนนี้ใช้แสดงข้อมูลจากตารางครับ
$tbl_users++;//อันนี้เป็นหน้า เช็ค admin
}
?>
index.php
<?
error_reporting(0);
session_start() ;
include('connect_db.php');
if(($mode=="admin") or ($mode=="user")) {
include('admin_chk.php');
}
?>
<?
// พื้นที่ทำงาน
if($mode=="admin") {
include('admin.php');
}elseif($mode=="user") {
include('std.php');
}elseif($mode=="adminmain") {
include('admin_main.php');
} else {
include('cms_index.php');
}
?>
Date :
11 ม.ค. 2551 01:13:27
By :
u-know
Load balance : Server 00