Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/mm/upp/ |
<?
require("db.php");
$link = dbConnect();
session_start();
if (isset($_SESSION['login_name'])){
$login_name = $_SESSION['login_name'];
$full_name = $_SESSION['full_name'];
$role = $_SESSION['role'];
$session_continue = 'TRUE';
}else{
$login_name = $_POST['login_name'];
$upwd = $_POST['upwd'];
}
// log out ppl with inactive from last 20 min.
// mysql_query("delete from auth where last_activity<NOW()-1200");
if (isset($_GET['LOGOUT'])){
session_unset();
session_destroy();
$id = "";
$login_name = "";
$full_name = "";
$role = "";
//setcookie("auto_login", "", time()-3600);
header("Location: index.php");
exit;
}
if (isset($_POST['LOGIN'])){
$login_name = $_POST['login_name'];
$upwd = $_POST['upwd'];
$rs = mysql_query("select * from users where login_name='$login_name' and password=password('$upwd')", $link);
if ($rs) {
$o = mysql_fetch_object($rs);
$id = $o->id;
$full_name = $o->full_name;
$role = $o->role;
$system_ip = $o->system_ip;
mysql_query("update users set last_login=now() where row_id=$row_id", $link);
session_register("id", "login_name", "full_name", "role", "system_ip");
if ($role == 'admin') {
header("Location: admin/index.php");
}elseif ($role == 'operator') {
header("Location: operator/index.php");
}else {
header("Location: index.php");
}
exit;
}
}elseif ($session_continue == 'TRUE'){
if ($role == 'admin') {
header("Location: admin/index.php");
}elseif ($role == 'operator') {
header("Location: operator/index.php");
}else {
header("Location: index.php");
}
exit;
}
?>