Page 1 of 1
Filtering unwanted characters!
Posted: Wed Apr 14, 2004 3:38 pm
by Joe
Hey. I have a problem with my registration script where users are entering unwanted characters like |, %, !, ), and so on. I was wondering if there is any technique to stop characters and numbers being entered apart from A-Z a-z 1-0. I know in most langauges theres a particular method but is there any for PHP.
Regards
Joe

Posted: Wed Apr 14, 2004 3:41 pm
by PrObLeM
Posted: Wed Apr 14, 2004 3:42 pm
by markl999
Or see
http://php.net/ctype_alnum
E.g if(!ctype_alnum($string)){ echo 'Invalid Characters'; } else { .... }
(I'll do anything to avoid regex

)
Posted: Wed Apr 14, 2004 3:48 pm
by MarK (CZ)
Regular expressions...
e.g.
Code: Select all
if (ereg("^їa-zA-Z0-9]+$", $input)) echo "Ok!";
Posted: Wed Apr 14, 2004 5:52 pm
by Joe
Thanks a lot. Everythink is running well now. And yeah mark i have heard around that its best to avoid regular expressions so i used your technique.
Regards
Joe
