Query on Security
-
Hi I am using the following code to screen variables prior to going into a database table.
I was just wondering if I have done it correctly or if there was a better way of doing it:
// Run variable input through filters $first_name = sanitize_text_field( $_POST['first_name'] ); $first_name = check_input( $first_name); $family_name = sanitize_text_field( $_POST['family_name'] ); $family_name = check_input( $family_name, "Please Enter a Family Name"); $sex = sanitize_text_field( $_POST['sex'] ); $sex = check_input( $sex, "Please Enter The Sex of the New Person"); $date_of_birth = sanitize_text_field( $_POST['date_of_birth'] ); $date_of_birth = check_input( $date_of_birth); $date_of_death = sanitize_text_field( $_POST['date_of_death'] ); $date_of_death = check_input( $date_of_death); include ('tablename.php'); $wpdb->insert($table_name,array('first_name'=>$first_name,'family_name'=>$family_name,'sex'=>$sex, 'date_of_birth'=>$date_of_birth, 'date_of_death'=>$date_of_death,'family_id'=>$family_name.$n)); function check_input($data, $problem='') { $data = strip_tags($data); $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { die($problem); } return $data; } include ('auto_new_page.php'); $wpdb->insert($table_name,array('person_id'=>$id));
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Query on Security’ is closed to new replies.