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? Link to comment https://forums.phpfreaks.com/topic/77509-only-allowing-certain-characters/ 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/77509-only-allowing-certain-characters/#findComment-392329 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 Link to comment https://forums.phpfreaks.com/topic/77509-only-allowing-certain-characters/#findComment-392360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.