OK first things first...
Cleanse ALL DATA before being submitted.
You can do this with functions to make sure the usernames are X amount of characaters and numeric or non numeric.
Next. What database is this?
No matter which what you want to do is this:
Create a temp table.
When a session is created meanign a vistor attmepts to login.. grap the IP of the system connecting.. and take timestamp and insert into session table.
Now on each refresh of the page or opening of the page you want to do a select * from sessions where ip="thatip";
If non exists then insert.
if it exists then you want to subtract now() from the timestamp.
if the user has exceeded 15 minutes then create a new record and force new login.
This will also prrotect inactive users inside the memember area.
Next... As far as blocking brute force attacks.. first we need to establish how this system is setup..
should ANYONE from the internet even be allowed to connecT?
if not then simple firewall will do...
If so.. then pop 3 entries into the table... on 4th entry where ip same.. deny access .
Just to a redirect to some access denied page.
I am not sure of your coding skills but these are simple GET and POST methods combined with the proper if statements.
I hope my advice has helped.