|
|
|
ช่วยเขียนโค้ด ระบบ login การใช้งาน แบ่งตามชนิดของผู้ใช้งาน |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
$username = $_POST["username"];
$password = $_POST["password"];
include 'connect.php';
$sert = "insert into monitor values('$username','$date','$time')";
mysql_query($sert) or mysql_errno();
$chk2= mysql_query("select servname,password
from server
where servname='$username'and password ='$password'");
$rows_num = mysql_num_rows($chk2);
if($rows_num>0 )
{
$rowchk = mysql_fetch_array($chk2);
$_SESSION['username'] = "$username";
$_SESSION['password'] ="$password";
{
header("Location:user_main.php");
}
}
else ($chk= mysql_query("select account,password
from login
where account='$username'and password ='$password'"));
{
$rows_num = mysql_num_rows($chk);
if($rows_num>0 ) {
$rowchk = mysql_fetch_array($chk);
$_SESSION['username'] = "$username";
$_SESSION['password'] ="$password";
{
header("Location:admin_main.php");
}
}
else
header("Location:logout.php");
}
?>
ก็เช็คตาม username+password หรืออื่นๆทั่วๆไป
ลองใช้ดเป็น header location ลิ้งไปตามหน้าต่างๆก็ได้ ลองดู
|
|
|
|
|
Date :
2010-12-03 15:06:12 |
By :
mzchewiize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sql = "select username, password, type from member where username = '$username' and password = '$password'";
$result = mysql_query($sql);
$rows = mysql_fetch_array($result);
$user = $rows["username"];
$type = $rows["type"];
if(isset($user)) //พบ username
{
$_SESSION["user"] = $user;
$_SESSION["type"] = $type;
}
else
{
echo "Error";
}
หน้าต่อไปก็เอา $_SESSION["type"] ไปทำกำหนดว่าใครจะเห็นส่วนไหน
พอจะได้ไหม
|
ประวัติการแก้ไข 2010-12-03 15:17:17
|
|
|
|
Date :
2010-12-03 15:15:25 |
By :
EucifeR |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยยกตัวอย่างให้ละเอียดหน่อยค่ะ
ไม่ค่อยเข้าใจ
สมมุติ
user = admin
pass = admin
type = admin
------
user =zone1
pass = zone1
type= zone1
ค่ะ
มีทั้งหมด 6 ระดับ
|
|
|
|
|
Date :
2010-12-03 16:38:27 |
By :
wongkhajang |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พยายามอีกหน่อยครับ ไม่ยากหรอก
|
|
|
|
|
Date :
2011-01-10 18:43:49 |
By :
กก |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|