how do I fillter chars like ` & ^ %
Filltering
Collapse
X
-
Ok here is what I got
PHP Code:$text = preg_replace('/[^[:alnum:]\-\.\_\^]/', '', $username); if($text == true) { die ("Unsupported character(s)"); }Last edited by ripkk2tfk; 09.01.10, 13:14.Visit my site
Comment
-
to prevent mysql injection use: mysql_real_escape_string
PHP: mysql_real_escape_string - Manual
Comment
-
one other way
put this in your confg.php or ini.php
PHP Code:function scharin($word) { $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; for($i=0;$i<strlen($word);$i++) { $ch = substr($word,$i,1); $nol = substr_count($chars,$ch); if($nol==0) { return true; } } return false; }
put this line in your register.php and you replace $login to your user name etc
andPHP Code:if(scharin($login) == true) $error=$error.'Invalid Characters in Nick!<br/>';
PHP Code:if(strlen($login)<3) $error=$error.'Nick should be Minimum of 3 words!<br/>';
if you need more and strong filter send me pm will tell you
Last edited by GiLL; 09.01.10, 16:19.left wap stuff
Comment
-
this is not a good solution to prevent mysql injectionOriginally posted by GiLL View Postput this in your confg.php or ini.php
PHP Code:function scharin($word) { $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; for($i=0;$i<strlen($word);$i++) { $ch = substr($word,$i,1); $nol = substr_count($chars,$ch); if($nol==0) { return true; } } return false; }
put this line in your register.php and you replace $login to your user name etc
andPHP Code:if(scharin($login) == true) $error=$error.'Invalid Characters in Nick!<br/>';
PHP Code:if(strlen($login)<3) $error=$error.'Nick should be Minimum of 3 words!<br/>';
if you need more and strong filter send me pm will tell you
Comment

Comment