WordPress.org

Support

Support » Plugins and Hacks » Contact Form 7 » [Plugin: Contact Form 7] Store form fields in DB?

[Plugin: Contact Form 7] Store form fields in DB?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Ya. I am too facing the same problem. Can anyone tell me where the DB Table is located in Contact Form 7 Plugin. I was not able to find it.

    I edited the functions.php file in the theme directory and I created a new function and added the hook:

    add_action('wpcf7_before_send_mail','save_to_db');
    
    function save_to_db($cf7) {
      //declare your varialbes, for example:
      $first_name = $cf7->posted_data["first-name"];
    
      //connect to the db and post the data
      mysql_connect(...) or die(...);
      mysql_select_db(...) or die(...);
      mysql_query("INSERT INTO MyTable (first_name
      ) VALUES('$first_name')") or die(...);
      mysql_close();
    }

    Doesn’t work for me, Can you help ?

    Here’s what I did. create ‘mytable’ varchar
    Added the following in …\themes\xxx\funtions.php

    add_action(‘wpcf7_before_send_mail’,’save_to_db’);

    function save_to_db($cf7) {
    //declare your varialbes, for example:
    $first_name = $cf7->posted_data[“your-name”];

    //connect to the db and post the data
    mysql_connect(‘localhost’) or die(‘localhost’);
    mysql_select_db(‘wordpress’) or die(‘wordpress’);
    mysql_query(“INSERT INTO mytable (name) VALUES(‘$first_name’)”) or die(‘mytable’);
    mysql_close();
    }’

    What am I doing wrong ?

    Please ignore my previous post.
    Does not seem to work with contact form 8.
    Back to contact form 7.

    There’s an addon for Contact Form 7 that adds data to DB: I haven’t tried it but its at http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/.

    For a fully featured premium plugin you cant go past Gravity Forms. It’s $40 for a single use license but well worth the investment. http://www.gravityforms.com/

    Just as an FYI, I am using the Contact Form 7 to Database Extension works like a charm

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Contact Form 7] Store form fields in DB?’ is closed to new replies.
Skip to toolbar