Viewing file: redir.php (1.72 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
session_start();
include_once('config.php');
// Check From Logout Page
if ($status == "logout") {
header("Location: login.php");
session_destroy();
$status = "logout";
}
else {
// Trim input box
$txtUser = trim($txtUser);
$txtPwd = trim($txtPwd);
connDB();
$sql = "select * from wp_users where user_id = '$txtUser' ";
$rs = mysql_query($sql);
if (mysql_num_rows($rs) > 0) {
$row = mysql_fetch_array($rs);
$password = $row[user_pass];
$gid = $row[gid];
$pwdCrypt = crypt($txtPwd, $password);
mysql_free_result($rs); // free user result
if ($password == $pwdCrypt) {
/******************************************************************************************************
*** Session Regist and Redirect to user page
******************************************************************************************************/
$_SESSION['gid'] = $gid;
$_SESSION['login'] = "True";
print "Redirect to ...";
switch ($gid) {
case 1:
header("Location: main.php?user=$row[uid]");
break;
case 2:
header("Location: home.php?user=$row[uid]");
break;
case 3:
header("Location: guest.php");
break;
default:
msgbox_loc("ไม่พบกลุ่มผู้ใช้นี้ในระบบ","login.php");
session_destroy();
}
}
else {
msgbox_loc("รหัสผ่านไม่ถูกเข้าระบบได้","login.php");
session_destroy();
}
}
else {
msgbox_loc("ไม่สามารถเข้าระบบได้","login.php");
session_destroy();
}
} // end if check logout page
?>
|