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

Subscribe to our news:
Partners
Testimonials
Kirby Foster: "Nice software. Small, lightweight, works well. I evaluated lots of software before deciding that your software worked the best for what I do. Both Maestro for MySQL and PHP Generator have saved me lots of time".
Philipp Gerber: "

The product is so easy and super built that you can achieve visible and great success after a short time. Also very much possible with the product. A class product. I'm already looking forward to the next versions and extensions. Keep it up.

Support to the product is just perfect. Each Support request is quickly and very competent solved. Also various assistance, which does not fall into a support, are also perfectly processed. There is a direct wire to the manufacturer / developer and this is notth. Thanks for the class Support".

More

Add your opinion

PHP Generator for MySQL online Help

Prev Return to chapter overview Next

OnAfterLogin

This event occurs after a user is successfully logged in into the application.

 

Signature:

function OnAfterLogin ($userName, $connection, &$canLogin, &$errorMessage)

 

Parameters:

$userName

The name of the logged user.

$connection

An instance of the EngConnection class.

$canLogin

Specifies whether a user can login (true by default). You can set the value of this parameter to false to disable login even for a user who provided valid credentials.

$errorMessage

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

 

Example 1:

Among other things this event can be used for tracking the user activity. The code snippet below inserts a new record containing user name and the login time into the 'log' table.

 

$connection->ExecSQL("INSERT INTO log(user_name, log_date) 

  VALUES ('$userName', CURRENT_TIMESTAMP)");

 

Example 2:

The following code allows to redirect users to home page after login.

 

header('Location: index.php');

exit;

 

Example 3:

The following code locks user account if number of failed login attempts exceeded otherwise the counter of failed login attempts is reset.

 

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

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

if ($failedLoginAttempts >= 3) {

  $canLogin = false;

  $errorMessage = 

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

} else {

  $sql = "UPDATE phpgen_users SET failed_login_attempts = 0 WHERE user_name='$userName'";

  $connection->ExecSQL($sql);

}

 

 

See also: OnAfterFailedLoginAttempt and OnBeforeLogout events



Prev Return to chapter overview Next