Posted By

nebojsac on 06/10/11


Tagged

mysql php function clean sanitize


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Sanitize user input PHP


 / Published in: PHP
 

URL: tricksbycinger.blogspot.com

The function returns the "sanitized" version of user input. Use before putting variables into SQL code.

  1. function sanitize($data)
  2. {
  3. $data = trim($data);
  4. {
  5. $data = stripslashes($data);
  6. }
  7. $data = mysql_real_escape_string($data);
  8. return $data;
  9. }
  10.  
  11. //example
  12. $username = sanitize($_POST['username']);

Report this snippet  

You need to login to post a comment.