|
|
|
login แบบมีผู้ใช้หลายประเภท คือจะทำหน้า login โดยมีผู้เข้าใช้ 3-4 ประเภทคือจะตรวจสอบ username และ password |
|
|
|
|
|
|
|
ศึกษาเรื่อง session ครับ สำหรับกำหนดตัวแปรแบบ session เพื่อใช้ตรวจสอบ ระดับของผู้ใช้ในการกำหนดสิทธิในการเข้าถึงไฟล์ต่าง ๆ
|
|
|
|
|
Date :
20 มี.ค. 2551 09:44:57 |
By :
trans |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไงผมก็เขียนไม่ได้ เลยแก้ปัญหาทำ login 4 อันในหน้าเดียวไปแล้วครับ เพราะเป็นงานรีบ ขายผ้าเอาหน้ารอดไปก่อน ผมเข้าใจว่ามันยากจริงๆครับ ในนี้จึงไม่ค่อยมีตัวอย่าง Code ให้ ผมเองเจอโจทย์นี้ก็งงเลย เล่นไปคนละทางเลย ขอขอบคุณทุกท่านที่ให้ความสนใจและให้ความช่วยเหลือครับ
|
|
|
|
|
Date :
20 มี.ค. 2551 22:00:17 |
By :
Boh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ที่ผมทำอยู่ตอนนี้ ก็ใช้คำสั่ง switch case คับ เช็คที่ ตัวแปร $auth
คุณต้องการมีกี่ User ก็ตามแต่ คุณก็ select เก็บไว้ในตัวแปร $sql ไปเรื่อย ๆคับ
ส่วน หน้าของ login ก็ทำแค่หน้าเดี่ยว แต่ ให้เขาระบุ ว่ามีสิทธิ เป็นใคร เช่น
admin ,Teacher, Employee, graduate ประมาณนี้ครับ
code ของผมเป็นการติดต่อ ฐานข้อมูล Sqlserver 2000 นะคับ
<?
session_start();
$md5pass=md5($txtpass);
include("config.php");
$sql1 = "select * from admin where username = '$txtuser' and password = '$md5pass' and auth_id='$auth' ";
$sql2= "select *from teacher where username='$txtuser' and password='$md5pass' and auth_id='$auth' ";
$sql3= "select *from employee where username='$txtuser' and password='$md5pass' and auth_id='$auth' ";
$sql4= "select *from graduate where grd_card_id='$txtuser' and grd_birthday='$md5pass' and auth_id='$auth' ";
switch ($auth){
case 1:
$execute = odbc_exec( $connection,$sql1) or die ("execute ไม่ได้");
while(odbc_fetch_row($execute))
{
$admin_id = odbc_result($execute,admin_id );
$admin_name=odbc_result($execute,name);
session_register("admin_id");
session_register("admin_name");
header('location:admin');
exit;
}
echo("<SCRIPT LANGUAGE='JavaScript'>
window.alert('ไม่มีผู้ใช้ในระบบครับ ! กรุณาติดต่อผู้ดูแลระบบ')
</SCRIPT>");
// echo"<div align='center'> <font size='3' color='#FF0000' ><b>ไม่มีผู้ใช้ในระบบ</b></font><br></div>";
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
odbc_free_result($execute);
odbc_close($connection);
break;
case 2:
$execute = odbc_exec( $connection,$sql2) or die ("execute ไม่ได้");
while(odbc_fetch_row($execute))
{
$teach_id = odbc_result($execute,teach_id);
$teach_name=odbc_result($execute,name);
session_register("teach_id");
session_register("$teach_name");
header('location:teach');
exit;
}
echo("<SCRIPT LANGUAGE='JavaScript'>
window.alert('ไม่มีผู้ใช้ในระบบครับ ! กรุณาติดต่อผู้ดูแลระบบ')
</SCRIPT>");
//echo"<div align='center'> <font size='3' color='#FF0000' ><b>ไม่มีผู้ใช้ในระบบ</b></font><br></div>";
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
odbc_free_result($execute);
odbc_close($connection);
break;
case 3:
$execute = odbc_exec( $connection,$sql3) or die ("execute ไม่ได้");
while(odbc_fetch_row($execute))
{
$returnvalue = odbc_result($execute,name );
echo "$returnvalue";
//header('location:profiles.php');
exit;
}
echo("<SCRIPT LANGUAGE='JavaScript'>
window.alert('ไม่มีผู้ใช้ในระบบครับ ! กรุณาติดต่อผู้ดูแลระบบ')
</SCRIPT>");
// echo"<div align='center'> <font size='3' color='#FF0000' ><b>ไม่มีผู้ใช้ในระบบ</b></font><br></div>";
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
odbc_free_result($execute);
odbc_close($connection);
break;
default:
$execute = odbc_exec( $connection,$sql4) or die ("execute ไม่ได้");
while(odbc_fetch_row($execute))
{
$returnvalue = odbc_result($execute,name );
echo "$returnvalue";
//header('location:profiles.php');
exit;
}
echo("<SCRIPT LANGUAGE='JavaScript'>
window.alert('ไม่มีผู้ใช้ในระบบครับ ! กรุณาติดต่อผู้ดูแลระบบ')
</SCRIPT>");
// echo"<div align='center'> <font size='3' color='#FF0000' ><b>ไม่มีผู้ใช้ในระบบ</b></font><br></div>";
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
odbc_free_result($execute);
odbc_close($connection);
}
?>
|
|
|
|
|
Date :
24 มี.ค. 2551 17:38:42 |
By :
pok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ของผมนี่เพิ่ม record สถานะมาครับ คือแยกสถานะคน แล้วตอน login ใช้ check สถานะเอา
|
|
|
|
|
Date :
31 มี.ค. 2551 15:02:58 |
By :
boyz79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|