|
 |
|
รบกวนพี่ๆๆด้วยค่ะ จะแบ่ง tbl person กับ admin แยกกันจะต้องทำยังไงค่ะ ตอนแรกเอามารวมกัน โดยใช้ p_IsAdmin เป็นเงื่อนไขอ่ะค่ะ |
|
 |
|
|
 |
 |
|
<?
session_start();
require_once("connect/connect.php");
?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<head><title>ตรวจสอบความถูกต้องของผู้ใช้สิทธิ</title></head>
<body style="font-family:'MS Sans Serif';font-size=12pt">
<?
//เริ่มการติดต่อกับฐานข้อมูล emc_test ใน MySQL
//include("StartConnect.inc");
//require_once("include/dbConnectstart.php");
require_once("include/inc_all.php");
/*$ServerName = "127.0.0.1";
$DatabaseName = "Training";
$User = "root";
$Password = "1234";
$Conn = mysql_connect($ServerName,$User,$Password) or die ("ไม่สามารถติดต่อกับเซิร์ฟเวอร์ได้");
mysql_select_db($DatabaseName,$Conn) or die ("ไม่สามารถติดต่อกับฐานข้อมูลได้");*/
//นำค่าที่ได้รับจากแบบฟอร์มด้วยวิธี POST มาเก็บไว้ในตัวแปร
$user = $_POST["user"];
$pass = $_POST["pass"];
$_SESSION['name'] = $user;
$_SESSION['pass'] = $pass;
$jsAction="window.location.href('Login.php');";
checkInputData($user,"",false,"กรุณาป้อนชื่อผู้ใช้คะ",$jsAction);
checkInputData($pass,"",false,"กรุณาป้อนรหัสด้วยคะ",$jsAction);
//$year = date("Y")+543;
//$date = date("m-d-$year H :i :s");
//อ่านค่าข้อมูลในเทเบิล myuser ที่ตรงกับ
//ชื่อผู้ใช้ในตัวแปร $user ซึ่งรับมาจากแบบฟอร์ม
$SQL = "SELECT p_Code, p_Fname, p_Lname, p_username, p_password ,p_IsAdmin, p_Level FROM person WHERE p_username = '$user' and p_password = '$pass' ";
//$table = mysql_query($SQL,$Conn) or die ("ไม่สามารถเรียกดูข้อมูลในเทเบิลได้");
$result = mysql_query($SQL);
$row = mysql_fetch_array($result);
//รับค่า authorize มาเพื่อมาใส่ตัวแปร และเอาไปตรวจสอบว่าเป็น Admin หรือเปล่า? ถ้าใช่จึงจะสามารถเข้า ADD position ของ HR
if (mysql_num_rows($result) > 0) {//ตรวจสอบว่าชื่อ รหัส และ authorize ถูกต้องหรือไม่?and isHRAdmin()
$_SESSION["ss_name"]=$user;
$_SESSION["ss_pass"]=$pass;
if($row["p_IsAdmin"] == 1 ){
$_SESSION["ss_role"] = "Admin";
}else{
$_SESSION["ss_role"] = "Person";
}
$_SESSION["ss_level"] = $row["p_Level"];
$_SESSION["p_code"] = $row["p_Code"];
$_SESSION["fullname"] = $row["p_Fname"] . " " . $row["p_Lname"];
$_SESSION["coursename"] = $row["course_Name"];
//echo "======>".$_SESSION["fullname"];
//echo "======>".$_SESSION["coursename"];
//exit();
if ( $row["p_IsAdmin"] == 1) {
?>
<script language ="JavaScript" >
window.location = "MainAdmin.php";
</script>
<?
//phpRedirect("main.php");
} else {
?>
<script language ="JavaScript" >
window.location = "MainUser.php";
</script>
<?
}
} else {
echo "<font color=#FF0000><b>ชื่อผู้ใช้และรหัสผ่านไม่ถูกต้อง</b></font><br>";
echo "กลับหน้าหลัก-> <a href='login.php'>คลิกที่นี่</a>";
//phpRedirect("login.php");
}
//ปิดการติดต่อกับฐานข้อมูล emc_test ใน MySQL
//mysql_free_result($table);
//mysql_close($Conn);
?>
</body>
</html>
อันนี้คือโค้ดในหน้า checkpermission ที่ใช้เช็คเวลาใครเข้าสู่ระบบอ่ะคร่ะ
ไม่รู้ว่าจะต้องแก้ยังงัยถึงจะให้ admin เข้าสู่ระบบได้
|
 |
 |
 |
 |
Date :
2010-09-17 15:58:47 |
By :
lebellela |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนด้วยคร้า
|
 |
 |
 |
 |
Date :
2010-09-17 16:58:47 |
By :
lebellela |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|