Title: Multiple forms submit to one database
Last modified: August 22, 2016

---

# Multiple forms submit to one database

 *  Resolved [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/)
 * I have seven forms. Each one opens opens a pdf brochure unique to that form once
   it has been filled out and SEND is clicked. But I would like the data from the
   forms to all go to the same database, i.e. People who have asked for a brochure.
 * I have seen some discussions about this but I couldn’t understand how to implement.
 * Thank you.
 * [https://wordpress.org/plugins/contact-form-7-to-database-extension/](https://wordpress.org/plugins/contact-form-7-to-database-extension/)

Viewing 15 replies - 1 through 15 (of 44 total)

1 [2](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/2/?output_format=md)

 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583299)
 * These are all be listed in the database under their different form names, but
   when retrieving information in a short code, you can get data from multiple forms
   as once as if they were just one form.
 * You can set `form="*"` to get information from all forms or list the form names
   using `form="form1,form2,form3` in a short code.
 * But if you really want to make the data all go into the same form name, follow
   the directions on [changing data before it is saved](http://cfdbplugin.com/?page_id=747)
   wherein you can intercept the form submissions and change their form name.
 *     ```
       function change_title($formData) {
           if ($formData && in_array($formData->title, array('form1', 'form2', 'form3')) {
              $formData->title = 'THE CONSOLIDATED FORM NAME YOU WANT";
           }
           return $formData;
       }
   
       add_filter('cfdb_form_data', 'change_title');
       ```
   
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583691)
 * Thank you for this, it’s going the right direction I think. But I am so lame 
   at coding that I don’t know how to create a database and I don’t know how to 
   write the code that would send the data from the seven forms to that database.
 * Any help is appreciated.
    Thank you.
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583693)
 * I’m giving you the code. You just have to fill in some blanks. I’ll make it simpler
   below. Use [Add Actions and Filters plugin](https://wordpress.org/plugins/add-actions-and-filters/screenshots/)
   to put in the code.
 *     ```
       function change_title($formData) {
          // change this: Pick a name. Any name not already used by a form
           $myUnifiedForm = 'THE CONSOLIDATED FORM NAME YOU WANT'; 
   
          // change this: list all the forms you want to consolidate. Replace FORM1 with the name of a form, etc. Add as many as you want. put commas between and use single quotes.
           $myForms = array('FORM1', 'FORM2', 'FORM3'); 
   
           if ($formData && in_array($formData->title, $myForms) {
              $formData->title = $myUnifiedForm;
           }
           return $formData;
       }
   
       add_filter('cfdb_form_data', 'change_title');
       ```
   
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583694)
 * Thank you Michael, I can now see how the structure works.
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583738)
 * Michael,
 * I got this error code above the box where the code goes –
 * Parse error: syntax error, unexpected ‘{‘ in /home/anasysin/public_html/wp-content/
   plugins/add-actions-and-filters/AddActionsAndFilters_Plugin.php(114) : eval()’
   d code on line 2
 * Warning: session_start() [function.session-start]: Cannot send session cache 
   limiter – headers already sent (output started at /home/anasysin/public_html/
   wp-content/plugins/add-actions-and-filters/AddActionsAndFilters_Plugin.php(114):
   eval()’d code:2) in /home/anasysin/public_html/wp-content/plugins/constant-contact-
   api/functions.php on line 5
 * Here is the code I put in;
    function change_title($formData) { if ($formData &&
   in_array($formData->title, array(‘Brochure Data Download AFM+’, ‘Brochure Data
   Download IR’, ‘Brochure Data Download IR2’, ‘Brochure Data Download nanoTA’, ‘
   Brochure Data Download Probes’, ‘Brochure Data Download SThM’)) { $formData->
   title = ‘Combined Brochure Forms’; } return $formData; }
 * add_filter(‘cfdb_form_data’, ‘change_title’);
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583739)
 * You’re missing a close-paren at the end of the if-statement. Try:
 *     ```
       function change_title($formData) {
           if ($formData && in_array($formData->title,
                           array('Brochure Data Download AFM+',
                                   'Brochure Data Download IR',
                                   'Brochure Data Download IR2',
                                   'Brochure Data Download nanoTA',
                                   'Brochure Data Download Probes',
                                   'Brochure Data Download SThM'))) {
               $formData->title = 'Combined Brochure Forms';
           }
           return $formData;
       }
   
       add_filter('cfdb_form_data', 'change_title');
       ```
   
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583740)
 * That worked, no error messages, thank you.
 * Another question. I put this code in the “Add Actions and Filters” tool and saved.
   When I go to Contact DB though, I don’t see it. Is there a step I missed?
 * Thank you,
    Will
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583741)
 * This applies to new submissions coming in.
 *  [lim sungbeom](https://wordpress.org/support/users/lim-sungbeom/)
 * (@lim-sungbeom)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583742)
 * Hello~
    I thank you for your great plugin and your kind guide.
 * I tried to modify my plug in as your guide.
    Combied DB was published, but there
   are another 5 db for each 6 form, also published
 * I combied from form1 to form 6 and I want to use just new one.
    I don’t need 
   each form db, How can it be deleted when combined DB is published.
 * Below is my code which is added using ‘Add Actions And Filter’
 * ——————Below————————–
 * function change_title($formData) {
    if ($formData && in_array($formData->title,
   array(‘Medical Record Check’, ‘Medical Record Check 2’, ‘Medical Record Check
   3’, ‘Medical Record Check 4’, ‘Medical Record Check 5’, ‘Medical Record Check
   6’))) { $formData->title = ‘Combined Medical Record Forms’; } return $formData;}
 * add_filter(‘cfdb_form_data’, ‘change_title’);
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583744)
 * It is not clear to me what your question is. Is it about deleting something?
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583747)
 * Michael,
 * I put the code (above) to the Add Actions and Filters plugin, then tested one
   of the contact forms, but the data did not read to a “Combined Brochure Forms”
   DB. When I go to “Contact DB” I don’t see Combined Brochure Forms listed in the
   pull down window. I did create a contact form called “Combined Brochure Forms”
   thinking that this would help initiate the DB, but it still doesn’t work. I’m
   stumped.
 * Any Help would be appreciated. Here’s some screen captures – [http://www.anasysinstruments.com/combined-brochure-databases/](http://www.anasysinstruments.com/combined-brochure-databases/)
 * Thank you,
    Will
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583748)
 * [@willbell](https://wordpress.org/support/users/willbell/)
    Creating a “Combined
   Brochure Forms” form definition is irrelevant and unnecessary.
 * Everything looks right in the screenshot that you show. I just set up my own 
   example and it works…
 * I see your code doesn’t have the same line breaks as what I posted above. Shouldn’t
   matter, but copy-paste my code, save and try a submission.
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583751)
 * I did as you suggested, tested and still no “Combined Brochure Forms” database.
   The data did show up in “Brochure Data Download AFM+”. If I have the code correct,
   is there something else with the setup that I could be missing? Does it matter
   that I’m running WP 3.6.1? Sorry to bother you so much but we’re so close and
   this is pretty important for me.
    Thank you.
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583752)
 * Are you sure there are no extra spaces at the beginning or end of the form names?
 *  Thread Starter [willbell](https://wordpress.org/support/users/willbell/)
 * (@willbell)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/#post-5583756)
 * Checked, same.
 * Here’s another thought. In the “Additional Settings” box for each of the forms
   I have this code:
 * on_sent_ok: “location = ‘[http://www.anasysinstruments.com/afm+_Brochure.pdf&#8217](http://www.anasysinstruments.com/afm+_Brochure.pdf&#8217);;”
 * Could this be causing a problem?
 * Thank you,
    Will

Viewing 15 replies - 1 through 15 (of 44 total)

1 [2](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/2/?output_format=md)

The topic ‘Multiple forms submit to one database’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-to-database-extension_ffffff.
   svg)
 * [Contact Form DB](https://wordpress.org/plugins/contact-form-7-to-database-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-to-database-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/reviews/)

## Tags

 * [Contact Form DB](https://wordpress.org/support/topic-tag/contact-form-db/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [Merge](https://wordpress.org/support/topic-tag/merge/)

 * 44 replies
 * 4 participants
 * Last reply from: [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/multiple-forms-submit-to-one-database/page/3/#post-5583819)
 * Status: resolved