Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include("../db.php");
- date_default_timezone_set("Asia/Kolkata");
- $a=date('Y-m-d G:i:s');
- $b=date('Y-m-d');
- $dtatmasteruser= mysql_query("select * from dm_admin where email='{$_POST['loginid']}' and password='{$_POST['upassword']}'");
- $dtatmasteruser_row=mysql_fetch_assoc($dtatmasteruser);
- if($dtatmasteruser_row['email']==$_POST['loginid'] && $dtatmasteruser_row['password']==$_POST['upassword'])
- {
- $_SESSION['username']="Admin";
- $_SESSION['aid']=$dtatmasteruser_row['id'];
- $_SESSION['pass']=$dtatmasteruser_row['password'];
- $resp=$_SESSION['aid'];
- $ipaddress = $_SERVER['REMOTE_ADDR'];
- $sqlGetLastLoginDate ="select DATE_FORMAT(logindate,'%b %d, %Y') as logindate, DATE_FORMAT(logintime, '%h:%i %p') as logintime, ipaddress from login_record where UniqueID = (select max(uniqueid) from login_record where userid = '" . mysql_real_escape_string($resp) . "')";
- $rslogouttime = mysql_query($sqlGetLastLoginDate);
- $rCount = mysql_num_rows($rslogouttime);
- if($rCount > 0)
- {
- $arrRec = mysql_fetch_array($rslogouttime);
- setcookie("LastLoginDateIP", "<B>Last login:</B> " . $arrRec["logindate"] . ' ' . $arrRec["logintime"] . ' from ' . $arrRec["ipaddress"]);
- }
- mysql_free_result($rslogouttime);
- $sqlPunchLogin = "insert into login_record (userid, logindate, logintime, ipaddress) values ('" . mysql_real_escape_string($resp) . "' ,'" . $b . "' ,'" . $a . "', '" . $ipaddress . "')";
- mysql_query($sqlPunchLogin);
- $sqlGetCurrLoginDate ="select DATE_FORMAT(logindate,'%b %d, %Y') as logindate, DATE_FORMAT(logintime, '%h:%i %p') as logintime, ipaddress from login_record where UniqueID = (select max(uniqueid) from login_record where userid = '" . mysql_real_escape_string($resp) . "')";
- $rslogouttime = mysql_query($sqlGetCurrLoginDate);
- $rCount = mysql_num_rows($rslogouttime);
- if($rCount > 0)
- {
- $arrRec = mysql_fetch_array($rslogouttime);
- setcookie("cLoginDateIP", "<B>Current login:</B> " . $arrRec["logindate"] . ' ' . $arrRec["logintime"] . ' from ' . $arrRec["ipaddress"]);
- }
- header("location:home.php");
- }
- else{
- echo '<script>window.location="index.php?message=Invalid Id or Password!!";</script>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement