I am wondering how to insert form input value to wordpress database.
In a wordpress theme, I want to add an input element and insert it to database.
Clicking the submit button, I think there is no effect to insert for the following codes.
<h1>wordpress_theme_file.php</h1>
<h1>database.php</h1>
In a wordpress theme, I want to add an input element and insert it to database.
Clicking the submit button, I think there is no effect to insert for the following codes.
<h1>wordpress_theme_file.php</h1>
Code:
<form id=”form_reply” action=”database.php” method=”post”>
…
<input type=”text” id=”newValue” name=”newValue” />
…
</form>
<h1>database.php</h1>
Code:
<?php
global $wpdb;
$inputValue = $_POST[‘ newValue ‘];
$wpdb->insert(‘wp_table_name’, ‘field_name’=>$inputValue); // wp_table_name and field_name in database
?>