Jump to content

Repetitive form submission


helraizer

Recommended Posts

Hi folks,

 

I have a form for the user to fill in with a comment and then post it... which is pretty normal.

 

However, anyone can just post and post and post..

 

What code could (or an idea of such) can I use to stop a certain IP address from posting more than 3 times in 10 minutes (for example)?

 

Sam

Link to comment
Share on other sites

Set up a table called "post_users" with 2 columns, IP and Time.

 

And everytime someone posts a comment, add their IP and Time to the DB. So each time (before putting the comment in the DB), check if their IP is in the "post_users" table within the last 10 minutes (time()-600)

 

:)

Link to comment
Share on other sites

You have to be careful about any approach that uses IPs to identify users.  A potential problem with an IP-based approach would be multiple users in the same public setting or company trying to post comments; they will all appear to come from the same IP as far as your site is concerned.

 

You could create a cookie on the client machine; but this is unreliable as well since a spammer can just delete them after each post.

 

The most reliable approach is one in which you require users to have an account before they can post.  Then you can use the initial solution proposed by wes but instead of the IP address, store the user's name.  If you ever wondered why every popular site required users to register, this is part of it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.