Advertisement

07.09.2007 at 08:35AM PDT, ID: 22683531
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

How to lock account based on X failed logins? PHP SQL

Asked by dialeradmin in MySQL Server, PHP for Windows, PHP and Databases

Tags: , ,

Hi.  I currently have a website in place that requires a user to login in order to participate.  I need to add a security feature that logs the number of times a user fails to login.  If the failed login attempts exceeds 5 within a 24 hour period, it locks the user account.  When the user account becomes blocked, it redirects to a certain page...let's say (account_locked.php).

How would I approach something like this?  

Here is my index.php in case that is needed for any suggestions.


index.php
=============
<?php
require_once('db.php');
include('functions.php');

if(isset($_POST['Login']))
{
      if($_POST['username']!='' && $_POST['password']!='')
      {
            $query = mysql_query('SELECT ID, Username, Active, Level_access FROM users WHERE Username = "'.mysql_real_escape_string($_POST['username']).'" AND Password = "'.mysql_real_escape_string(md5($_POST['password'])).'"');
                  
            if(mysql_num_rows($query) == 1)
            {
                  $row = mysql_fetch_assoc($query);
                  if($row['Active'] == 1)
                  {
                        session_start();
                        $_SESSION['user_id'] = $row['ID'];
                        $_SESSION['logged_in'] = TRUE;
                        $_SESSION['Level_access'] = $row['Level_access'];
                              
                        switch($row['Level_access'])
                        {
                            case 1:
                        {
                                 header("Location: control_panel.php");
                                  break;
                        }
                            case 2:
                        {
                                  header("Location: control_panel.php");
                                  break;
                        }
                        }
                  }
                  else {
                  $error = 'Your user account was not activated. Please open the email that was sent and click on the activation link.';
            }
      }
            else {            
                  header("Location: login_fail.php");            
            }
            }
      else {
            $error = 'Please enter both your username and password to access your account';
      }
}
?>

<?php if(isset($error)){ echo $error;}?>Start Free Trial
[+][-]07.09.2007 at 10:55AM PDT, ID: 19447227

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MySQL Server, PHP for Windows, PHP and Databases
Tags: failed, mysql, php
Sign Up Now!
Solution Provided By: richswyatt
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.09.2007 at 10:57AM PDT, ID: 19447249

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32