Posted By

atinamedia on 11/30/06


Tagged

login php inputs securing cleaning


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

hkmd
politicalanimal
hudge
skywalker
vali29
tapdrup
ninjacharlee


Securing & Cleaning Strings in inputs like Login, etc.


 / Published in: PHP
 

By Eduardo de la Torre.

  1. <?php
  2. // SECURE STRINGS IN LOGIN ETC.
  3. // By Eduardo de la Torre from www.atinamedia.com
  4.  
  5. function clean_string($string, $length){
  6. $string = substr($string, 0, $length);
  7. $string = strip_tags(trim($string));
  8. return $string;
  9. }
  10.  
  11. // Example:
  12. // If... Triying XSS
  13.  
  14. $foo = "<scrip>alert(\"ALARM!!\");</script>";
  15.  
  16. // The length is limit to 40 characters (for example)
  17. echo clean_string($foo, 40);
  18. ?>

Report this snippet  

You need to login to post a comment.