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!!
You can easily connect to another DB using the
$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
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
protected by fuxia♦ Aug 1 '14 at 7:43
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?