Jump to content

Login Count


Panta

Recommended Posts

please can some one help me . I'm new to php environment . I need an ideal on how to write a script that counts the login success of a user.And when the user login successfully 3 times he or she will be ban from login in unless he or she obtained a new password.thanks. im watin

Link to comment
Share on other sites

I suppose you mean unsuccessful login attempts? You could have an additional field in your table that records the amount of attempts, which gets reset when they successfully log in. If, when you check it, it is above three, then you don't allow the login and tell them to visit the reset page, or whatever.

Link to comment
Share on other sites

I suppose you mean unsuccessful login attempts? You could have an additional field in your table that records the amount of attempts, which gets reset when they successfully log in. If, when you check it, it is above three, then you don't allow the login and tell them to visit the reset page, or whatever.
no. what i need is a script that counts the successful login and with a particular password, and when the password is used for 3 successful login, the user needs to get a new password for him to access the site again.and the new password will only be use for 3 times. thanks watin
Link to comment
Share on other sites

I would imagine you could just put an IF ELSE statement inside the block which figures out if it was a successful login and save the counts. So something like this. Change the details of the script to make it work. The script is assuming you have a new field in your table which has the counter for the password. (I have not tested this out).

$qry = mysql_query("SELECT password_count FROM [table] WHERE user='$user'");$row = mysql_fetch_array($qry);$cnt = $row['password_count'];if ($cnt != 3) {  $cnt++;  mysql_query("UPDATE [table] SET password_count='$cnt' WHERE user='$user'");}else {  echo "Password was used three times.";}

Link to comment
Share on other sites

I would imagine you could just put an IF ELSE statement inside the block which figures out if it was a successful login and save the counts. So something like this. Change the details of the script to make it work. The script is assuming you have a new field in your table which has the counter for the password. (I have not tested this out).
$qry = mysql_query("SELECT logins FROM [users] WHERE username='$user'");$row = mysql_fetch_array($qry);$cnt = $row['logins'];if ($cnt != 3) {  $cnt++;  mysql_query("UPDATE [users] SET logins='$cnt' WHERE username='$user'");//set $_SESSION['username'] to the username from database$_SESSION['username'] = $r['username'];header("Refresh: 7; url=index.php?i=idx");echo'<center>Login successfull!</center>';//else, if there werent any records found show an error and //return the user to index.}else{header("Refresh: 2; url=index.php?i=idx");echo "<center>You couldn't be logged in!</center>";}}?>

thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...