How to filter all form input fields for escape characters in PHP

If you have a large number of form fields which you would like to filter for escape characters in PHP then you can use the following 3 line code to at the start of your form field processing code. Please note that this method is not completely safe however if you are writing some code for an internal web application which will not be accessible to the public then you can use it but please consider the risks before using it.

 $val) {
   $_GET[nam] = addslashes(strip_tags($val));
}
?>

or

 $val) {
   $_POST[nam] = addslashes(strip_tags($val));
}
?>

I hope the above helped.

Please follow and like us:
error

Be the first to comment

Leave a Reply

Your email address will not be published.