Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a contact form (Contact Form 7) that submits all fields into a mySQL database (via the Contact Form 7 to Database Plugin), everything is working fine with that. I want it to however, throw the sender an error message if the e-mail address field has already been submitted. (And of course not submit the data).

What's the easiest most painless way to do this?

My database's name is wordpress

The table's name is wpcf7dbplugin_submits

share|improve this question
Here is a suggestion, don't post a question on 4+ sites at the same time, closing, stackoverflow.com/questions/14984094/… –  Wyck Feb 20 '13 at 16:43
add comment

2 Answers

The easiest way would be to first query the database to see if a row containing the email address already exists, and if it does throw the error - otherwise store the information as normal.

If you post the code you use to add entries into the database I can try to give you an example.

share|improve this answer
To add entries to the database, I used the contact form DB plugin. wordpress.org/extend/plugins/… I changed the variavle $wpdb to $mydb and defined $mydb in my functions.php file. –  collin Feb 20 '13 at 16:37
add comment

You could make email part of the primary key and it would throw an exception and handle that exception on the other end. Not sure how contact form 7 handles exceptions

share|improve this answer
Could you provide some sample code to demonstrate this solution? –  s_ha_dum Feb 20 '13 at 17:33
Sure let me install the contact form plugin and Ill take a quick look in the morning. –  Blake Feb 20 '13 at 21:33
With the table structure my idea wont work. Its an options table so Josh is correct. –  Blake Feb 21 '13 at 1:34
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.