What I would do is store all of their login attempts and if they try to login unsuccessfully three times within a certain window, say 30 minutes, then they have to wait until their first login attempt goes beyond that first 30 min login window to try again.
So, have a database table, say "logins" with a primary key of "arbitrary_id", that stores login attempts. Then query the database for all login attempts within the 30 min window. If the number of results equals 3 or more then deny access.
SELECT COUNT(arbitrary_id) FROM logins WHERE user_id=$user_id AND DATE_SUB(CURDATE(), INTERVAL 30 MINUTE) <= last_login;
"last_login" is the DATETIME value of when they tried to login