Execute a SQL Statement on WordPress Login

Solution:

WordPress has many so-called action hooks that allow you to do thing when certain events occur. There is one called wp_login that fires whenever someone logs in.

You can add the following to your functions.php file:

function log_login() {
// update what you want in the database
}
add_action('wp_login', 'log_login');

This will get called whenever someone logs in.