You need what is called a password search box.
Basically 2 fields in the database, one LastPasswordAttempt (datetime) and PasswordAttemptCount (int)
Then at each login, check when the last LastPasswordAttempt occurred, and if it was the last, say 10 minutes - increase the PasswordAttemptCount, otherwise reset by 0 (or 1, because they just worked).
In the same logic, check if PasswordAttemptCount is equal to 5 or more, if this is to deny the user access. You may have a 3rd field that blocks them for several hours or a day.
i.e. CanLoginAfter (datetime), which you can set per day from the last password attempt.
Hope this helps
Marko source share