WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Store form fields in DB? (7 posts)

  1. lynx
    Member
    Posted 4 years ago #

    Hi!

    Is there a way to store the values from the forms in the database? I need to store them and export them from time to time in csv.
    Any solution for this?

    Bye!

    Jens

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Trivikrama
    Member
    Posted 4 years ago #

    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.

  3. gwbiffar
    Member
    Posted 4 years ago #

    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();
    }
  4. kalariak
    Member
    Posted 4 years ago #

    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 ?

  5. kalariak
    Member
    Posted 4 years ago #

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

  6. patnz
    Member
    Posted 3 years ago #

    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/

  7. docnzok
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic