Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners
Testimonials
Mike Little: "Great product, thank you for your great work and sharing".
Grey: "We're a two-person company, it's just me an my wife. I'm the technical guru, and she handles the business operations. I have to know a lot about MySQL, but that's much too technical for her. I have frequently had to setup CGI scripts (I code in Perl) so she can manage some of our tables (suppliers, manufacturers, etc).

I discovered PHP Generator a couple of days ago, tried the free version,and within a few hours I had purchased the Pro version (as well as SQL Maestro for MySQL).

Today I am completing the conversion of the last of my custom table managers to PHP Generator. This is eliminating several thousand lines of code that I don't have to support any more!

Thanks for this fantastic product".

More

Add your opinion

PHP Generator for MySQL online Help

Prev Return to chapter overview Next

OnAfterFailedLoginAttempt

This event occurs after a failed login attempt. It allows you to trace failed login attempts. The event is usually used in conjunction with OnAfterLogin event. For example, you can limit the number of failed login attempts per user and to lock user account after a number of failed login attempts.

 

Signature:

function OnAfterFailedLoginAttempt ($userName, $connection, $&errorMessage)

 

Parameters:

$userName

The name of the logged user.

$connection

An instance of the EngConnection class.

$errorMessage

A message to be displayed when valid credentials are provided, but $canLogin == false.

 

Example:

 

function OnAfterFailedLoginAttempt($userName, $connection, &$errorMessage)

{

  // Retrieve a number of previous failed login attempts

  $sql = "SELECT failed_login_attempts FROM phpgen_users WHERE user_name='$userName'"

  $failedLoginAttempts = $connection->ExecScalarSQL($sql);

 

  // Add a current failed login attempt  

  $failedLoginAttempts++;

 

  // Display message based on a number of failed login attempts   

  if ($failedLoginAttempts == 2) {

    $errorMessage = 'You have one attempt left before your account will be locked.';

  } elseif ($failedLoginAttempts == 3) {

    $errorMessage = 'Too many failed login attempts. Your account has been locked.';

  } elseif ($failedLoginAttempts > 3) {

    $errorMessage = 

      "Dear $userName, your account is locked due to too many failed login attempts. " .

      'Please contact our support team.';

  }

 

  // Update a number of failed login attempts in users table

  if ($failedLoginAttempts <= 3) { 

    $sql = 

      "UPDATE phpgen_users " .

      "SET failed_login_attempts = $failedLoginAttempts " .

      "WHERE user_name='$userName'";

    $connection->ExecSQL($sql);

  }

}

 

 



Prev Return to chapter overview Next