WordPress.org

Ready to get started?Download WordPress

Forums

Form sending data to two different databases (3 posts)

  1. marcrock
    Member
    Posted 2 years ago #

    Hello.

    I have a page with a form. I'd like when the user clicked on the submit button its data was sent to two different databases. I think this could be done via a function inside the functions.php file. Could anyone show me a simple and efficient way to do that?

    Thanks!

  2. Shyam Kumar 2012
    Member
    Posted 2 years ago #

    on wp-config.php,
    define('DB_NAME', 'db1');

    put your database name over there where your wp_tbl1 exist.say db1.
    put this query together and when onclick event will oddours both will be fired.

    $wpdb->query("INSERT INTO wp_tbl1 (ID, name) VALUES (NULL, 'abc')");

    $wpdb->query("INSERT INTO db2.wp_tbl2 (T_ID, emp_name) VALUES (NULL, 'employee name')");

    I hope this will help you.

    Thanks,
    Shyam

  3. marcrock
    Member
    Posted 2 years ago #

    Hello, Shyam.
    Thank you very much for your reply. My client had urgency to solve that problem and he hired a programmer to do it. But I really appreciate your message and will be trying your solution. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic