Quick and easy flood protection?

Posted by James P on Stack Overflow See other posts from Stack Overflow or by James P
Published on 2010-06-11T22:23:47Z Indexed on 2010/06/11 23:33 UTC
Read the original article Hit count: 187

Filed under:
|
|

I have a site where a user submits a message using AJAX to a file called like.php. In this file the users message is submitted to a database and it then sends a link back to the user. In my Javascript code I disabled the text box the user types into when they submit the AJAX request.

The only problem is, a malicious user can just constantly send POST requests to like.php and flood my database. So I would like to implement simple flood protection.

I don't really want the hassle of another database table logging users IPs and such... as if they are flooding my site there will be a lot of database read/writes slowing it down. I thought about using sessions, like have a session that contains a timestamp that gets checked every time they send data to like.php, and if the current time is before the timestamp let them add data to the database, otherwise send out an error and block them. If they are allowed to enter something into the database, update their session with a new timestamp.

What do you think? Would this be the best way to go about it or are there easier alternatives?

Thanks for any help. :)

© Stack Overflow or respective owner

Related posts about php

Related posts about protection