Skip to content

Commit

Permalink
block hacking attampts done
Browse files Browse the repository at this point in the history
blocking hacking attampts done
  • Loading branch information
Fahad-Md-Kamal committed Mar 5, 2019
1 parent 42dda10 commit 99c419e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion php/loginChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
$email = $_POST['email'];
$pass = $_POST['pass'];

if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}


if (empty($email)) {
$_SESSION['msg'] = "Please enter valid email address";
}elseif (empty($pass)) {
Expand All @@ -16,14 +21,21 @@
$conn = DataBaseConnection();

$sql = "SELECT * FROM users WHERE email ='$email' AND pass = '$pass' ";
if($result = $conn->query($sql)){
$result = $conn->query($sql);
if($result->num_rows > 0){
foreach($result AS $row){
$_SESSION['userName']= $userName = $row['name'];
}
$_SESSION['loggedIn'] = true;
$_SESSION['msg'] = "Hey<br> $userName <br>Welcome Back ";
unset($_SESSION['count']);
}else{
$_SESSION['msg'] = "Invalid Username or Password";
$_SESSION['count']++;

if($_SESSION['count'] >= 3){
setcookie('loginCounter', true, time() + 10);
}
}
}
header("location:../login.php");
Expand Down

0 comments on commit 99c419e

Please sign in to comment.