Sanitization of php forms in PHP Posted March 6, 2018 · Edited March 6, 2018 by oxk4r fix code Hi. I have a doubt with the proper way of sanitize the forms with php. In the php form validation lesson https://www.w3schools.com/php/php_form_validation.asp is used a function for this purpose: function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } But in the filters lesson, https://www.w3schools.com/php/php_filter.asp I understand that filters can do the same task. Is this correct? Are two approaches valid? Which one should be used nowadays? Thanks in advance!
Sanitization of php forms
in PHP
Posted · Edited by oxk4r
fix code
Hi. I have a doubt with the proper way of sanitize the forms with php. In the php form validation lesson https://www.w3schools.com/php/php_form_validation.asp is used a function for this purpose:
But in the filters lesson, https://www.w3schools.com/php/php_filter.asp I understand that filters can do the same task. Is this correct? Are two approaches valid? Which one should be used nowadays?
Thanks in advance!