Code: Select all
} else {
$var1 = $var1 + 1;
$invalidLogin = 'Invailid Username/Password! This has happened: '.$var1.' time(s). 2 more and your banned!';
}How do I accomplish this?
Moderator: General Moderators
Code: Select all
} else {
$var1 = $var1 + 1;
$invalidLogin = 'Invailid Username/Password! This has happened: '.$var1.' time(s). 2 more and your banned!';
}Code: Select all
} else {
$_session['invalid_attempt'] = $_session['invalid_attempt'] + 1;
$invalidLogin = 'Invailid Username/Password! This has happened: '.$_session['invalid_attempt'].' time(s). 2 more and your banned!';
}I cannot get it...waqas_punjabian wrote:U should just replace $var1 with the $_SESSION['invalid_attempt'], where ever u r using it at the top or at the middle. there's no need to do session_start() again because u 've already it once.
Code: Select all
<?php
session_start();
$_SESSION['invalid_attempt'] = 0;
$errorMessage = 'You Better Really Be An Admin If You Are Here. 3 Invalid Login Attempts Will Get You A Permanent Ban From The Site And An Email Will Be Sent To Us Containing The Username(s) And Password(s) You Entered, The Date And Time, And Your IP Address.';
if (isset($_POST['txtUserName']) && isset($_POST['txtPassword'])) {
// connect to database here
include('config.php');
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
$username = $_POST['txtUserName'];
$password = $_POST['txtPassword'];
$sql = "SELECT id, nickname, username
FROM $table
WHERE username = '$username' AND password = '$password'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
list($userid, $nickname, $username) = mysql_fetch_array($result);
if (($userid) >= 1) {
$_SESSION['userid'] = $nickname;
print " <font size="1" face="Arial"> Welcome, $_SESSION[userid] <a href="logout.php">Logout</a></font>";
} else {
$_SESSION['invalid_attempt'] = $_SESSION['invalid_attempt'] + 1;
$invalidLogin = 'Invailid Username/Password! This has happened: '.$_session['invalid_attempt'].' time(s). 2 more and your banned!';
}
mysql_close();
}
?>should not you suppose to increment $_SESSION['invalid_attempt'].ORiGIN wrote:http://evgclan.net/new/newlogin.php - That is where it is locatedCode: Select all
<?php session_start(); $_SESSION['invalid_attempt'] = 0; ?>
Thanks for that, but how would I fix this? I tried doing this instead, but it still won't work...Mohamed wrote: should not you suppose to increment $_SESSION['invalid_attempt'].
in ever page load you are resetting variable to 0
Code: Select all
if ( $_SESSION['invalid_attempt'] > 0 ) {
// Do Nothing
} else {
$_SESSION['invalid_attempt'] = 0;
}Code: Select all
$_SESSION['invalid_attempt'] = 0;Code: Select all
if ( $_SESSION['invalid_attempt'] > 0 ) {
$_SESSION['invalid_attempt']++;
} else {
$_SESSION['invalid_attempt'] = 0;
}Code: Select all
<?php
session_start();
if(isset($_SESSION['invalid_attempt'])){
$_SESSION['invalid_attempt']+=1;
}
else {
$_SESSION['invalid_attempt']=0;
}
?>Thanks for all of your help, but it won't work. I have no idea why, but it just does not want to work. Logging in works perfect. But when it is wrong it just refreshes the page and nothing changes. I guess I don't really need to ban anybody. I was eventually going to use that as an admin login page, but seeing how I am a noob I will notMohamed wrote:here is the code
Code: Select all
<?php session_start(); if(isset($_SESSION['invalid_attempt'])){ $_SESSION['invalid_attempt']+=1; } else { $_SESSION['invalid_attempt']=0; } ?>