clean user input data ( GET, POST, COOKIE )


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

Created for my own purposes, thought I'd share though ;)

copy paste at the top of your file and it does the magic :)


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. function clean($value)
  4. {
  5. if (get_magic_quotes_gpc()) $value = stripslashes($value);
  6.  
  7. if (!is_numeric($value)) $value = mysql_real_escape_string($value);
  8.  
  9. return $value;
  10. }
  11.  
  12. array_walk($_GET,'clean');
  13. array_walk($_POST,'clean');
  14. array_walk($_COOKIE,'clean');
  15.  
  16. extract($_GET,EXTR_PREFIX_ALL,'get');
  17. extract($_POST,EXTR_PREFIX_ALL,'post');
  18. extract($_COOKIE,EXTR_PREFIX_ALL,'cookie');
  19.  
  20. ?>

URL: http://www.meelsonwheels.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.