Posted By

jdmyers on 01/06/10


Tagged


Versions (?)

Data Cleaning Function


 / Published in: PHP
 

URL: php

  1. ################################################################
  2. #
  3. # Data Cleaning Function
  4. # - helps prevent MySQL injection, use when building the query after database connecton established
  5. # - Original Source: http://www.digital-web.com/articles/bulletproof_contact_form_with_php/
  6. # - trim function added by me
  7. #
  8. ################################################################
  9. function cleanData($string)
  10. {
  11. {
  12. // strip slashes if mahic quotes are on
  13. $string = stripslashes($string);
  14. }
  15. // remove unwanted HTML (not allowed)
  16. $string = strip_tags($string);
  17. // trim any leading and trailing whitespace
  18. $string = trim($string);
  19. // return the string with escaping slashes
  20. return mysql_real_escape_string($string);
  21. }

Report this snippet  

You need to login to post a comment.