Author Topic: Mod user bad name or minimum and maximum username  (Read 6083 times)

0 Members and 1 Guest are viewing this topic.

Offline jotabonfim

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Mod user bad name or minimum and maximum username
« on: September 24, 2008, 09:50:46 PM »
Hello boys, I would like to know if a module where I can control the amount of letters that the user types in time to make him the register on the site.
Example: the user would have to enter at least 5 letters to make the register and no more than 12 letters.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Mod user bad name or minimum and maximum username
« Reply #1 on: September 25, 2008, 12:11:25 AM »
in register.php find
      $sql "SELECT ".get_user_table_field("""user_name")."
              FROM "
.USERS_TABLE."
              WHERE "
.get_user_table_field("""user_name")." = '".strtolower($user_name)."'";


Insert below:
$lang['username_too_long'] = "Username is too long";
$lang['username_too_short'] = "Username is too short";
      if (
strlen($user_name) > 12)
      {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_too_long'];
        
$error 1;
      }
      elseif (
strlen($user_name) < 4)
      {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_too_short'];
        
$error 1;
      }
      else
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline jotabonfim

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: Mod user bad name or minimum and maximum username
« Reply #2 on: September 25, 2008, 02:10:27 AM »
Hello Vano thanks for your help!
Tackling the mine site with your help.


In the same module is possible I use a function that validate the user's character?
Example 1: ok paulobrasil can record in the database
Example 2: paulo&brasil (& invalid characters) do not let record in the database

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Mod user bad name or minimum and maximum username
« Reply #3 on: September 25, 2008, 02:34:20 AM »
Lets assume you know REGEX a little ;)

$lang['username_too_long'] = "Username is too long";
$lang['username_too_short'] = "Username is too short";
$lang['username_illegal_characters'] = "Username can only contein latin letters and numbers";
      if (
preg_match("/[^a-zA-Z0-9]/"$user_name))
      {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_illegal_characters'];
        
$error 1;
      }
      if (
strlen($user_name) > 12)
      {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_too_long'];
        
$error 1;
      }
      elseif (
strlen($user_name) < 4)
      {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_too_short'];
        
$error 1;
      }
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline jotabonfim

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: Mod user bad name or minimum and maximum username
« Reply #4 on: September 26, 2008, 02:41:30 PM »
Thank you for your Vano always help.  :D

It was great!! :P :thumbup:

Offline niad

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Mod user bad name or minimum and maximum username
« Reply #5 on: September 10, 2009, 09:12:25 AM »
Hi V@no,
How about adding this mod for the guest names in comments?
Sometimes they put very long names and the structure of the comments area is getting very bad
I love 4images, it is really great work!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Mod user bad name or minimum and maximum username
« Reply #6 on: September 10, 2009, 02:57:01 PM »
insert that code in details.php above
    if ($user_name == "")  {
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)