Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to sanitize POST data?

Tags:

wordpress

I am working on a WordPress plugin and need to sanitize the POST data within this function. Would sanitize_text_field() be the best way to go about it? Also what is the proper way to add it to the code below?

header( 'Content-Type: application/json' );

        global $wpdb;
$session_id = $_POST['session_id'];
        $procedure_name =  $wpdb->prefix . 'get_geojson_route';
        $gps_locations = $wpdb->get_results($wpdb->prepare(
            "CALL {$procedure_name}(%s);", 
            array(
                $session_id
            )
        )); 
like image 866
stpetedesign Avatar asked Oct 12 '25 00:10

stpetedesign


1 Answers

To sanatize post data wordpress give function :

$title = sanitize_text_field( $_POST['title'] );

Try this

like image 86
Rakhi Prajapati Avatar answered Oct 14 '25 19:10

Rakhi Prajapati