pouncer Posted November 23, 2006 Share Posted November 23, 2006 Currently I have this:[code=php:0] function IsValidUsername($Username) { if ($Username && strlen($Username) > 3) return true; else return false; }[/code]How can i expand to make sure the characters entered are characters a-z or A-Z or 0-9 ? Link to comment https://forums.phpfreaks.com/topic/28281-username-validity-check/ Share on other sites More sharing options...
steelmanronald06 Posted November 23, 2006 Share Posted November 23, 2006 That would be regular expressions. Of course in this instance if you just didstripslasheshtmlenetiesyou would pretty much be in the clear. Regex is mainly for email validation and things that must be string specific Link to comment https://forums.phpfreaks.com/topic/28281-username-validity-check/#findComment-129320 Share on other sites More sharing options...
trq Posted November 23, 2006 Share Posted November 23, 2006 [code=php:0]if ( preg_match('/^[a-zA-Z0-9_]{3,}$/', $Username )) return true;[/code] Link to comment https://forums.phpfreaks.com/topic/28281-username-validity-check/#findComment-129323 Share on other sites More sharing options...
pouncer Posted November 23, 2006 Author Share Posted November 23, 2006 Woah, thanks thorpe. Link to comment https://forums.phpfreaks.com/topic/28281-username-validity-check/#findComment-129325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.