Connect forms in WP to external database

I want to use WordPress for an existing site (coded in PHP). It has some forms (for member subscription, user can update their data etc.) which are connected directly to an existing database.
I don’t want to touch or change the DB, because it’s a huge member database. So my problem now is – how can I use a contact form within wordpress which sends the data automatically to this existing database?
Thanks for your help!!

Related posts

Leave a Reply

1 comment

  1. You can easily connect to another DB using the wpdb class: $external_users_db = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); (substituting in your applicable values, of course).

    From there you can use the get_results, insert, update, and query methods (among others) to do what you need to do, e.g. $external_users_db->get_results( "SELECT ID, username FROM users" );.

    The Codex has pretty thorough information: http://codex.wordpress.org/Class_Reference/wpdb