Solution samowns Posted April 30, 2022 Solution Share Posted April 30, 2022 (edited) i want to embed Bann Script or user deactive or active <?php session_start(); $message=""; ?> <?php include "db.php"; $msg=''; if(isset($_POST['sb'])) { $time=time()-30; $ip_address=getIpAddr(); $name = mysqli_real_escape_string($a, $_POST['eml']); $pass = mysqli_real_escape_string($a, $_POST['pass']); $query=mysqli_query($a,"select count(*) as total_count from loginlogs where TryTime > $time and IpAddress='$ip_address'"); $check_login_row=mysqli_fetch_assoc($query); $total_count=$check_login_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 $result=mysqli_query($a,"SELECT * FROM admin WHERE eml='$name' and pass= '$pass'"); $row = mysqli_fetch_assoc($result); $row=mysqli_num_rows($result); //ban user if($row==1) { $_SESSION['user_name'] =$name; header("location:wel.php?msg=Scuessfull eml"); mysqli_query($a,"delete from loginlogs where IpAddress='$ip_address'"); } else{ $total_count++; $rem_attm=4-$total_count; if($rem_attm==0){ $msg="To many failed login attempts. Please login after 40 sec"; }else{ $msg="<b>Please enter valid login details.<br/>$rem_attm attempts remaining <b>"; } $try_time=time(); mysqli_query($a,"insert into loginlogs(IpAddress,TryTime) values('$ip_address','$try_time')"); } }} if(isset($_SESSION['user_name']) ){ header("location:wel.php?msg=Scuessfull "); ?> <?php } ?> <form class="login-form" action="adminscure.php" method="post" > <div class="message"><?php if($message!="") { echo $message; } ?></div> <body id="LoginForm"> <div class="container"> <div class="main-div"> <div class="panel"> <h2>Admin Login</h2> <p>Please enter your email and passwords</p> </div> <form id="Login"> <div class="form-group"> <input type="name" name="eml" class="form-control" id="eml" placeholder="name"> </div> <div class="form-group"> <input type="password" name="pass" class="form-control" id="pass" placeholder="Password"> </div> <div> <input type="submit" name="sb" class="btn btn-primary"> <div id="result"><?php echo $msg?></div> </div> </form> <?php 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; }?> Edited April 30, 2022 by samowns Quote Link to comment https://forums.phpfreaks.com/topic/314742-user-bann-script/ Share on other sites More sharing options...
gw1500se Posted April 30, 2022 Share Posted April 30, 2022 So what is your question or error message? Quote Link to comment https://forums.phpfreaks.com/topic/314742-user-bann-script/#findComment-1595837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.