This is a discussion on How to test a string for invalid chars ? within the PHP Language forums, part of the PHP Programming Forums category; I think I am having a big blind-spot day. How does one test a form-sent string for any ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. Pjotr -- The day Microsoft starts making stuff that does not suck will undoubtedly be the day they start producing vacuum cleaners |
|
|||
|
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!'; } |