Regex PHP, alphanumeric
I check and see if the usernames being entered are alphanumeric. I use the
following code:
if(!preg_match("/^[a-z0-9]([0-9a-z_-\s])+$/i", $username)){
My problem is when I was trying it out, if I type in "(&(^&(&(" it will
come back as "Username not alphanumeric", however if I just try one
letter, for example: A, it will return "Username not alphanumeric". It
only happens if I type in single letters, and submit them. If I type in 2
letters, it works fine. Any reason why it's doing it for one letters?
Thank you.
No comments:
Post a Comment