Skip to content

Instantly share code, notes, and snippets.

@Asraful-Haque
Last active July 22, 2016 06:48
Show Gist options
  • Save Asraful-Haque/dd723cd2d04d2ea5ecfdac73c64489a1 to your computer and use it in GitHub Desktop.
Save Asraful-Haque/dd723cd2d04d2ea5ecfdac73c64489a1 to your computer and use it in GitHub Desktop.
myprint
<?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>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment