What is the correct way sanitizing form data before submitting to the database? I have the following text input:
<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
<input style="width:100%" type="text" name="data[title]" id="title" value="<?php $title = get_option('data_test'); echo $title['title']; ?>" /></p>
<input type="hidden" name="action" value="update"/>
<input type="hidden" name="page_options" value="lu_ban_data"/>
<input style="float:left;margin-top: 10px; margin-bottom: 10px; vertical-align: middle; clear: both;" class="button-primary" type="submit" value="<?php _e('save changes') ?>" />
</form>
I tried doing echo sanitize_text_field($title['title']);
, but it only sanitizes the data upon requesting it from the db, the data inside the db still contains unwanted characters. This is why I want to sanitize before submitting it.