frijole Posted February 10, 2008 Share Posted February 10, 2008 I am trying to validate usernames and passwords for a registration. I only want to allow letters and numbers. here is what I have, does this make sense? foreach($_POST as $field => $value) { if (!empty($value) { if (eregi("name", $field) and !eregi ("login", $field)) { if (eregi("^[A-Za-z' -]{1,50}$",$value)) { $errors[] = "$value is not a valid name."; } } } } Quote Link to comment https://forums.phpfreaks.com/topic/90418-validating-username-and-password/ Share on other sites More sharing options...
marcus Posted February 10, 2008 Share Posted February 10, 2008 if(!ctype_alnum($value)){ $errors[] = "Invalid name"; } Quote Link to comment https://forums.phpfreaks.com/topic/90418-validating-username-and-password/#findComment-463540 Share on other sites More sharing options...
frijole Posted February 11, 2008 Author Share Posted February 11, 2008 thanks, just what I was looking for. SOLVED Quote Link to comment https://forums.phpfreaks.com/topic/90418-validating-username-and-password/#findComment-463598 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.