Page 1 of 1

checking postdata validity with... ereg?

Posted: Sat Jun 18, 2005 9:21 pm
by robster
Hi,

I have a username field in a registration page I am creating. I've done a check to see if the user fills it in, if they don't it spits and tells them to fill it in. Now I want to do a check to see if they have illigal characters including spaces in the username postdata. ie (!@#$%^&*() ":;',./., etc etc ;))

I've had a good search through these forums and google and had a look at ereg but didn't fully understand it.

Just wondering if somebody could point me in a good direction or send a psuedo snippit or similar?

Any help appreciated.

Rob

Posted: Sat Jun 18, 2005 10:17 pm
by Skara
preg > ereg

if underscores count,

Code: Select all

if (preg_match('/\w+/',$string)) {
If they don't,

Code: Select all

if (preg_match('/[a-z]+/i',$string)) {

Posted: Sun Jun 19, 2005 12:27 am
by Ambush Commander
Looks like you probably want a tutorial on regular expressions (google that).