Blocking "User Creation" with special characters and spaces in "Username"? Blocking "User Creation" with special characters and spaces in "Username"?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Blocking "User Creation" with special characters and spaces in "Username"?

Started by fmk, January 02, 2011, 02:29:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fmk

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.
FMK

Love doesn't stop by my door, I am always infatuated with new things.

Αndré

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?

fmk

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.
FMK

Love doesn't stop by my door, I am always infatuated with new things.

Αndré

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>';
    }

fmk

FMK

Love doesn't stop by my door, I am always infatuated with new things.