use a field called logon_attempts, default it to 0 (zero).
use a field called logon_block, timestamp.
if the logon_block timestamp is in the future, the account is blocked. else if the user login is successful, set logon_attempts to 0 (zero) and let them in.
if the user password is invalid use update table set logon_attempts=logon_attempts+1 where user...
if the user password is invalid and logon_attempts = 3 they have had their 3 logon attempts, so you can lock the account by setting the contents of logon_block to 5 minutes in the future.