Jump to content

Simple duplicate protection


tibberous

Recommended Posts

I have a contact form, and I want to make sure it doesn't send a bunch of duplicates if the page is refreshed after being submitted.

 

Simple way is to make sure this record isn't identical to the one before it:

 

select * from `contacts` where `Name`='$name' and `Phone`='$phone' and `Message`='$message' and `Subject`='$subject' and `Email`='$email'

 

But, that checks against all records. While not likely, this could cause problems, if the same customer came back a month later and put in the same exact contact. Any way I can check it only against the very last record in the database? Something like: and `id`=XX , where XX is one less than the current auto inc id?

Link to comment
Share on other sites

Does your table have an id or anything to indicate where it was sent?

 

I'd select the most recent entry, based on the ID or timestamp, that matches your inputs. If it's within a few minutes (or seconds), you know to ignore it. If it's older than that, it's a valid new form.

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.