ataria Posted November 24, 2006 Share Posted November 24, 2006 Hopefully I got the title right..alright, what I am looking to do..is to have the username be a-z, A-Z, 0-9 ONLY.In an if statement please. (if possible).thanks in advance! Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/ Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 [code]if (!ereg("~!@#$%^&*()_+=-,./<>?;':"[]\{}|",$username)) { echo "$username is not a valid username"; }[/code] Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129365 Share on other sites More sharing options...
trq Posted November 24, 2006 Share Posted November 24, 2006 I swear this question was asked half hour ago.[code=php:0]if ( preg_match('/^[a-zA-Z0-9_]+$/', $user) ) { // valid}[/code] Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129366 Share on other sites More sharing options...
brendandonhue Posted November 24, 2006 Share Posted November 24, 2006 [code=php:0]if(ctype_alnum($username)){ //valid}[/code] Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129368 Share on other sites More sharing options...
ataria Posted November 24, 2006 Author Share Posted November 24, 2006 Awesome.Thanks guys! Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129370 Share on other sites More sharing options...
ataria Posted November 24, 2006 Author Share Posted November 24, 2006 Would it matter if I used all 3?such as, if (!ereg("~!@#$%^&*()_+=-,./<>?;':"[]\{}|",$username)) { echo "$username is not a valid username"; }elseif ( preg_match('/^[a-zA-Z0-9_]+$/', $user) ) { // valid}elseif(ctype_alnum($username)){ //valid}? Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129371 Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 I would stick with one of them. Use thorpes. Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129372 Share on other sites More sharing options...
ataria Posted November 24, 2006 Author Share Posted November 24, 2006 Alright.Thanks! Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129373 Share on other sites More sharing options...
brendandonhue Posted November 24, 2006 Share Posted November 24, 2006 [quote author=mgallforever link=topic=116102.msg472869#msg472869 date=1164331334]Use thorpes.[/quote]Out of curiosity, why that one? Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129398 Share on other sites More sharing options...
ataria Posted November 24, 2006 Author Share Posted November 24, 2006 Hey.Would that make spaces not allowed? Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129401 Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 It would make it so only a-z, A-Z and 0-9 are allowed. Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129404 Share on other sites More sharing options...
ataria Posted November 24, 2006 Author Share Posted November 24, 2006 I take that as a yes. XD Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129407 Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 And brendan, I chose his because I wasn't sure on ataria's PHP Experience level and to show that it would only include those. Link to comment https://forums.phpfreaks.com/topic/28290-username-character-limitations/#findComment-129409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.