Jump to content
Sign in to follow this  
Panta

Login Count

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Ooh I see. Well, just count the successful logins in the database then!

Share this post


Link to post
Share on other sites
Ooh I see. Well, just count the successful logins in the database then!
please can you show me how

Share this post


Link to post
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.";}

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...