Form sending data to two different databases (3 posts)

  1. marcrock
    Posted 4 years ago #


    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?


  2. Shyam Kumar 2012
    Posted 4 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.


  3. marcrock
    Posted 4 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