aenigma Posted July 20, 2008 Share Posted July 20, 2008 Hey, I was wondering if there was a way to make sure a string from an input box doesn't contain anything except a-z and 1-0 without checking an entire string against every character I don't want. Thanks for any help! Quote Link to comment Share on other sites More sharing options...
mga_ka_php Posted July 20, 2008 Share Posted July 20, 2008 use regex Quote Link to comment Share on other sites More sharing options...
aenigma Posted July 20, 2008 Author Share Posted July 20, 2008 Well, although that was REALLY vague, lol, I managed to read enough to figure it out. Here's what I came up with: if (!ereg("^[a-zA-Z0-9_]{4,16}$", $_POST["uname"])) { echo "Invalid Username<br>Usernames must be between 4 and 16 characters, contain only alphanumeric characters and \"_\""; $allchecks = 0; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.