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

put on hold as off-topic by toscho Jul 25 at 13:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the 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

2 Answers 2

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

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

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