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."; } } } } 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"; } 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 Link to comment https://forums.phpfreaks.com/topic/90418-validating-username-and-password/#findComment-463598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.