Many people has asked the same question, I have read those things and mine is different,
I am trying to insert some values inside the database from the form but it's not getting inserted
I have a table in the database having 6 columns wanted to insert some values inside only of 4 columns
Table Name: wp_contactus
6 Columns
- id
- firstname
- lastname
- query
- reg_date
This is the code for inserting only in the 4 columns
4 Columns
- firstname
- secondname
query
<div class="wrap"> <form action="" method="post"> FirstName <input type="text" name="firstNametxt" value="" /><br/> LastName <input type="text" name="lastNametxt" value="" /><br/> email <input type="text" name="email" value="" /><br/> Query <input type="text" name="query" value="" /><br/> <input name="Submit" type="submit" value="Submit"> </form> <form method="post"> <?php global $wpdb; $firstName = $_POST["firstNametxt"]; $lastName = $_POST["lastNametxt"]; $email = $_POST["email"]; $query = $_POST["query"]; echo $firstName; $contactus_table = $wpdb->prefix."contactus"; $sql = "INSERT INTO $contactus_table (id, firstname, lastname, email, query, reg_date) VALUES ('2', $firstName, $lastName, $email, $query, CURRENT_TIMESTAMP);"; $wpdb->query($sql)) ?> </form> </div> <?php } add_shortcode( 'CONUS', 'contactus_shortcode' ); ?>
id,
after$contactus_table