PHP sanitize variables


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //SANITIZE ALL DATA
  2. $_GET = array_map('trim', $_GET);
  3. $_POST = array_map('trim', $_POST);
  4. $_COOKIE = array_map('trim', $_COOKIE);
  5. $_REQUEST = array_map('trim', $_REQUEST);
  6. $_GET = array_map('stripslashes', $_GET);
  7. $_POST = array_map('stripslashes', $_POST);
  8. $_COOKIE = array_map('stripslashes', $_COOKIE);
  9. $_REQUEST = array_map('stripslashes', $_REQUEST);
  10. endif;
  11. $_GET = array_map('mysql_real_escape_string', $_GET);
  12. $_POST = array_map('mysql_real_escape_string', $_POST);
  13. $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
  14. $_REQUEST = array_map('mysql_real_escape_string', $_REQUEST);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.