i need a user-definatable string (IE when signing up for a user account, creating a log in name) to be completley alpha numeric.. with no nasty chars in it anywhere. ie.. l337d0wd would be fine... but l33=d()wd would cause "Invalid username" to be reported back
the code i had "if(ereg("[[:alnum:]]", $uname))" would stop the first charactor being non-alpha numberic (IE it couldn't be @) but it didn't stop speach marks ("

or colons

) and if the non-aplha numeric charactor was in the second slot of the string (IE p@) it would let it through
KarveR's code ( if (!ereg("[a-zA-Z0-9]+", stripslashes($uname))) ) also produced the same results. with the exception, it prevented the " and : problem (as " and : don't fall in a-z A-Z or 0-9)however it would only check the first charactor.
i think the only way i'm going to be able to do this succesfully would be with a for loop, and some javascript, which checks the string, sets the value of a hidden form element, and passes that to the php script, which i can then if-test to see it it's, true or false.
if anyone has any better ideas, please let me know.
Cheers.
/Sib
programmer in the making
icq: 44167565
e-mail: siberdude@ntlworld.com