Forums

Checking for duplicate entries when a form is submitted

andy_m 25 Jan, 2010
Ok, I have searched the forums for the past few days trying to find the answer to my problem.

I have a form where people subscribe to an event. However, it is possible in its current form to sign up for the event with the same details twice or more. This is a pain as some people have a habit of signing up more than once, normally because they forget.

I would like to have the form check the the person's details are not in the database already for the event. And for it to return a statement saying that they have already signed up for the event.

I know that I have to perform a MYSQL query and that it would look something like this but I don't know how to implement it on the form.

SELECT * FROM $table_name WHERE date = '$date_chosen' AND email = '$email_given' ;


Also where would I add it to the code.

I am very new to php and I don't have much experience. So any help will be appreciated
GreyHead 25 Jan, 2010
Hi andy_m,

Assuming that this is a public form (not for signed in registered members only) then the place to check is either in server-side validation or in the OnSubmit Before box. You will need to wrap up your query in some more code - there are plenty of examples here of what you will need.

Bob
andy_m 25 Jan, 2010
It was a public form.

Thanks for your advice I have got it working now.🙂

I have to say it is a great product.
This topic is locked and no more replies can be posted.