Hello,
I have a problem with the users whose names contain special and unusual characters like: , ą, ó, ł and underscore.
Problem is, because username is passing to some script, and that script does not recognize these characters.
It is possible to rework scirpt so as to block these characters?
www.pawelfoto.com
Sorry, i am absentminded. I would like block it on registration page - register.php
Quote from: pawelfoto on December 15, 2009, 09:44:13 PM
I would like block it on registration page - register.php
Edit register.php, find
function check_user_info(&$error)
and add your custom validation code, e.g. after
if (utf_strlen($user_name) < 2) $error .= '<li>' . $lang_register_php['err_uname_short'];
in a new line you might add something like
if (!eregi("^[0-9a-zA-Z]$", $user_name)) $error .= '<li>Illegal character in username' ;
Quote from: pawelfoto on December 15, 2009, 09:41:40 PMProblem is, because username is passing to some script, and that script does not recognize these characters.
Better option: edit that other script to allow special characters.
Hi
There is somethong wrong .. :-[
after adding the lines of code are blocked all the characters... Even if I want to register a user "abcd" I gets message - Illegal character in username.
if (!eregi("^[*-@-:-']$", $user_name)) $error .= '<li>Illegal character in username' ;
I included the characters that do not want them to be used for register. Not know if I can help you!
Quote from: VEGA on December 16, 2009, 04:27:26 PM
if (!eregi("^[*-@-:-']$", $user_name)) $error .= '<li>Illegal character in username' ;
I included the characters that do not want them to be used for register. Not know if I can help you!
That's clever :)
I need to check it.
Better to revert the logic by removing the exclamation mark: you probably haven't thought of all harmfull chracters. A whitelist is better than a blacklist in this aspect.
Finally I made it in this way:
if (eregi("([^abcdefghijklmnopqrstuvwxyz0123456789])", $user_name)) $error .= '<li>Nieprawidłowy znak w nazwie użytkownika.' ;
This meets my expectations in 100%
http://php.net/manual/en/function.eregi.php
...and what exactly is so different about your way? What's the use of if (eregi("([^abcdefghijklmnopqrstuvwxyz0123456789])", $user_name)) $error .= '<li>Nieprawidłowy znak w nazwie użytkownika.' ;
in comparison toif (eregi("([^a-z0-9])", $user_name)) $error .= '<li>Nieprawidłowy znak w nazwie użytkownika.' ;