Hi Guys,
A newbie + no programmer.
I need help with blocking "User Creation" with special characters and spaces in Usernames. I have edited text instructions in lang/english.php accordingly but want such attempts to be prohibited.
http://igallery.khanz.net
Thanks in advance.
What shall happen if you detect unwanted characters? Do you want to automatically replace them? Do you want to display an error message? Which characters to you want to allow?
Allowed characters - Users must register with either "firstname.lastname" or "firstname" or "lastname. I want a-z allowed and No spaces, and special characters like hyphen, underscores, etc. My users are able to register with a space in the user name.
Q-What shall happen if unwanted characters are detected?
A-Page should return an error asking user for correction. Form data should not be lost though.
Q-Do you want to automatically replace them?
A-Its a nice idea, but users may get confused, so No.
Open register.php, find
if (utf_strlen($user_name) < 2) {
$error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['username_warning2'] . '</li>';
}
and replace with
if (utf_strlen($user_name) < 2) {
$error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['username_warning2'] . '</li>';
} elseif (preg_match('/[^A-Za-z]/', $user_name)) {
$error .= '<li style="list-style-image:url(images/icons/stop.png)">' . 'Username must only contain a-z' . '</li>';
}
Works great. Thanks a lot Andre.