tibberous Posted November 15, 2007 Share Posted November 15, 2007 I am trying to only allow letters and numbers in the usernames for my site. Does anyone know what function checks to make sure a username like that is valid? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 15, 2007 Share Posted November 15, 2007 EDIT: Oops, code edited, works now. With REGEX <?php $username = "someUsername"; if (!eregi("[^a-zA-Z0-9]", $username)){ echo "VALID"; } else { echo "INVALID"; } ?> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted November 15, 2007 Share Posted November 15, 2007 if(ctype_alnum($username)) { echo "valid"; } else { echo "invalid"; } Faster 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.