frank_solo Posted May 13, 2011 Share Posted May 13, 2011 Ok so I'm still having problems. This is what I need: I want a function to echo a message if a username does not pass my requirments. - Only letters and / or numbers - Must start with a letter (not a number) - No spaces The current code is not working for me. Please help }else if (!(eregi('/[A-Za-z0-9-]+',($_POST["username"])))){ echo "<p> </p><p> </p><p> </p><br />Must only contain numbers and letters and cannot exceed 10 characters.<p> </p><p> </p><a href='javascript:javascript:history.go(-1)'>Click here to go back to previous page</a>"; Link to comment https://forums.phpfreaks.com/topic/236335-function-to-check-username-without-spaces/ Share on other sites More sharing options...
requinix Posted May 13, 2011 Share Posted May 13, 2011 if (ctype_alnum($username) && ctype_alpha(substr($username, 0, 1)) && strlen($username) // valid } Link to comment https://forums.phpfreaks.com/topic/236335-function-to-check-username-without-spaces/#findComment-1215083 Share on other sites More sharing options...
frank_solo Posted May 13, 2011 Author Share Posted May 13, 2011 That didn't work for me. Link to comment https://forums.phpfreaks.com/topic/236335-function-to-check-username-without-spaces/#findComment-1215195 Share on other sites More sharing options...
jcbones Posted May 13, 2011 Share Posted May 13, 2011 How did it "not work" for you? Link to comment https://forums.phpfreaks.com/topic/236335-function-to-check-username-without-spaces/#findComment-1215196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.