How to save data from an HTML form to a database table in WordPress? How to save data from an HTML form to a database table in WordPress? database database

How to save data from an HTML form to a database table in WordPress?


You are correct; in order to insert data into a database table, it is a best practice to use $wpdb. The WordPress Codex can provide you with examples and more information to help you proceed.

For example, to insert a new record into a database table, you can do this (from the above linked page):

$wpdb->insert( 'table', array( 'column1' => 'value1', 'column2' => 123 ), array( '%s', '%d' ) )

If you post additional code (e.g., how does addrow.php currently try to save the data?), we might be able to provide more specific information.