|
|
|
ช่วยด้วยครับ เขียนเป็นตัวอย่างให้หน่อยครับ ตามรูปที่แนบมาครับ ขอบคุณครับ |
|
|
|
|
|
|
|
ที่ 1 2 3 4 นี่ privileage หรือ id คับ เห็น priveleage มี 4 ตัวอักษร แบบ char ซะด้วย
|
|
|
|
|
Date :
2009-11-14 21:06:53 |
By :
pjgunner |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$username=trim($_POST['username']);
$password=trim($_POST['password']);
$result=mysql_query("Select * From tbregister Where username='$username' and password='$password'");
$num=mysql_num_rows($result);
if($num==0){
echo"ไม่พบข้อมูล";
} else {
$row=mysql_fetch_array($result);
$id=$row['id'];
$username=$row['username'];
$name=$row['name'];
$status=$row['status'];
session_register('username');
session_register('name');
session_register('id');
session_register('status');
if($row['status']=="1"){
//papg1
}
else if($row['status']=="2"){
//papg2
}
else if($row['status']=="3"){
//papg3
}
else if($row['status']=="4"){
//papg4
}
}
เอาไปดันแปลงเล่นดูนะครับ
|
|
|
|
|
Date :
2009-11-14 21:07:41 |
By :
somparn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 2 3 4 เป็น privileage ครับ
|
|
|
|
|
Date :
2009-11-16 21:07:45 |
By :
tui |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับคุณ : somparn
ผมลองทำแล้วทำไม่ได้อ่ะครับ ช่วยอีกหน่อยครับ
|
|
|
|
|
Date :
2009-11-16 21:09:13 |
By :
tui |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันขึ้นว่าไม่พบข้อมูล ผมต้องแก้ตรง table อย่างเดียวใช่มั้ยครับ
|
|
|
|
|
Date :
2009-11-16 21:10:55 |
By :
tui |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วถ้าแบบนี้จะแก้ยังงัยครับlogin ได้userเดียว
code ครับ
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['User'])) {
$loginUsername=$_POST['User'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "Privilege";
$MM_redirectLoginSuccess = "page1.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connectinon, $connectinon);
$LoginRS__query=sprintf("SELECT Username, Password, Privilege FROM account WHERE Username='%s' AND Password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $connectinon) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'Privilege');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
|
|
|
|
|
Date :
2009-11-16 21:27:35 |
By :
tui |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|