Insert data from form to database

Hello people on this forum!

I have a question, I need to insert some data from a form that I created to the database , I have tried this code:

if (isset($_POST[‘submit’])) {

global $wpdb;

$tablename=$wpdb->prefix.’verstuur’;

$data=array(
‘titel’ => $_POST[‘titel’],
‘url’ => $_POST[‘url’],
‘content’ => $_POST[‘content’]);

$wpdb->insert( $tablename, $data);
}

The HTML code is as following:

<form method=”POST” id=”verstuur”>
<label> Titel: </label>
<input name=”titel” type=”text” /><br>
<br>
<label> URL: </label><br>
<input name=”url” type=”url” />

<label> Content: </label>
<textarea cols=”6″ name=”content” rows=”8″></textarea>

<a href=”https://sshm.eu” name=”toevoegen”>Toevoegen</a>

Read more here:: Insert data from form to database

Leave a Reply

Your email address will not be published. Required fields are marked *