Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include("../db.php");
  4. date_default_timezone_set("Asia/Kolkata");
  5. $a=date('Y-m-d G:i:s');
  6. $b=date('Y-m-d');
  7. $dtatmasteruser= mysql_query("select * from dm_admin where email='{$_POST['loginid']}' and password='{$_POST['upassword']}'");
  8.  
  9. $dtatmasteruser_row=mysql_fetch_assoc($dtatmasteruser);
  10.  
  11.  
  12. if($dtatmasteruser_row['email']==$_POST['loginid'] && $dtatmasteruser_row['password']==$_POST['upassword'])
  13. {
  14.  
  15. $_SESSION['username']="Admin";
  16. $_SESSION['aid']=$dtatmasteruser_row['id'];
  17. $_SESSION['pass']=$dtatmasteruser_row['password'];
  18. $resp=$_SESSION['aid'];
  19. $ipaddress = $_SERVER['REMOTE_ADDR'];
  20. $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) . "')";
  21. $rslogouttime = mysql_query($sqlGetLastLoginDate);
  22. $rCount = mysql_num_rows($rslogouttime);
  23. if($rCount > 0)
  24. {
  25. $arrRec = mysql_fetch_array($rslogouttime);
  26. setcookie("LastLoginDateIP", "<B>Last login:</B> " . $arrRec["logindate"] . ' ' . $arrRec["logintime"] . ' from ' . $arrRec["ipaddress"]);
  27. }
  28. mysql_free_result($rslogouttime);
  29.  
  30. $sqlPunchLogin = "insert into login_record (userid, logindate, logintime, ipaddress) values ('" . mysql_real_escape_string($resp) . "' ,'" . $b . "' ,'" . $a . "', '" . $ipaddress . "')";
  31. mysql_query($sqlPunchLogin);
  32.  
  33. $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) . "')";
  34. $rslogouttime = mysql_query($sqlGetCurrLoginDate);
  35. $rCount = mysql_num_rows($rslogouttime);
  36. if($rCount > 0)
  37. {
  38. $arrRec = mysql_fetch_array($rslogouttime);
  39. setcookie("cLoginDateIP", "<B>Current login:</B> " . $arrRec["logindate"] . ' ' . $arrRec["logintime"] . ' from ' . $arrRec["ipaddress"]);
  40. }
  41.  
  42. header("location:home.php");
  43. }
  44. else{
  45. echo '<script>window.location="index.php?message=Invalid Id or Password!!";</script>';
  46.  
  47. }
  48.  
  49.  
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement