PHP Blocking access to the login page

Tuesday, November 3, 2015

I just want to Limit the number of login attempts
(after three attempts the user will be locked out)



I have the users and passwords in the database already



<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['userName'])) {
$loginUsername=$_POST['userName'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conn_helpdesk, $conn_helpdesk);

$LoginRS__query=sprintf("SELECT userName, password FROM technician WHERE userName=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $conn_helpdesk) or die(mysql_error());

$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {

$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
echo "erorr";
}
header("Location: " . $MM_redirectLoginSuccess );
}
}
?>


How can implement that into my code?
PS: This code was generated by Dreamweaver.

0 comments:

Post a Comment