View Single Post

  #2 (permalink)  
Old 11-04-2004
Thomas Mlynarczyk
 
Posts: n/a
Default Re: How to test a string for invalid chars ?

Also sprach Pjotr Wedersteers:

> I think I am having a big blind-spot day. How does one test a
> form-sent string for any disallowed characters again ? I want only
> a.z,A..Z,0..9,- and _ in the input... Thanks.


if(!preg_match('/^[a-zA-Z0-9_-]*$/', $input)) {
echo 'Invalid input!';
}
else {
echo 'Well done!';
}



Reply With Quote