How to validate my form

I am trying to build a plugin, in the plugin I want the admin to be able to send data to database and let the user view the data in the front end, but I am still having problems with sending data to database

I am trying to validate this code to keep it safe from injection
This is my code

<?php
if (!empty($_POST)) {
global $wpdb;
$table = wp_save;
$data = array(
‘name’ => $_POST[‘yourname’],
‘chord’ => $_POST[‘number’]
);
$format = array(
‘%s’,
‘%s’
);
$success=$wpdb->insert( $table, $data,
$format );
if($success){
echo ‘data has been save’ ;
}
} else {
?>
<form method=”post”>
<input type=”text” name=”yourname”>
<textarea name=”number”></textarea>
<input type=”submit”>
</form>
<?php
}
?>

Read more here:: How to validate my form

Leave a Reply

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