$time and IpAddress='".$ip_address."'");
$row = mysqli_fetch_array($query);
$total_count=$row['total_count'];
//Checking if the attempt 3, or youcan set the no of attempt her. For now we taking only 3 fail attempted
if($total_count==3){
$msg="To many failed login attempts. Please login after 30 sec";
}else{
//Getting Post Values
$username=$_POST['username'];
$password=$_POST['password'];
// Coding for login
$res=mysqli_query($conn,"select * from users where user_name='$username' and password='$password' and login_status = '1'");
if(mysqli_num_rows($res)){
$row = mysqli_fetch_assoc($res);
$_SESSION['IS_LOGIN']='yes';
$_SESSION['username']=$row['applicant_name'];
mysqli_query($conn,"delete from tbl_login where IpAddress='".$ip_address."'");
echo "";
}else{
$total_count++;
$rem_attm=3-$total_count;
if($rem_attm==0){
$msg="To many failed login attempts. Please login after 30 sec";
}else{
$msg="Please enter valid login details.
$rem_attm attempts remaining";
}
$try_time=time();
mysqli_query($conn,"insert into tbl_login(IpAddress,timeDiff) values('$ip_address','$try_time')");
}}
}
// Getting IP Address
function getIpAddr(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$ipAddr=$_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ipAddr=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ipAddr=$_SERVER['REMOTE_ADDR'];
}
return $ipAddr;
}
?>