Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Block arraynames so users can't use them

    Hello i would like to block so people can't use the names Admin and more in register. But I'm not sure how to do it. Anyway i also want to add so they can't use ADMIN or AdMIN i talking about [a-zA-Z]

    $nln = array('admin', 'moderator', 'owner', 'hoster', 'webmaster');

    if ($regnickname == $nln) {
    $errors[] = "You can't use the names Admin, Moderator, Hoster, Webmaster or Owner.";
    }

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    try something like that:
    PHP Code:
    $regnickname 'aDmIn';
    $reserved = array(
        
    'admin',
        
    'guru',
        
    'webmaster',
        
    /*
        .
        .
        .
        */
    );
    foreach(
    $reserved as $value){
        if(
    preg_match("/^" $value "$/i"$regnickname)){
            echo 
    'error: wrong name';
        }


  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    240
    Thanks
    1
    Thanked 56 Times in 55 Posts
    PHP Code:
    $nln = array('admin''moderator''owner''hoster''webmaster');
    $username 'AdmIn';
    $errors = array();
    if (
    in_array(strtolower($username), $nln))
            
    $errors[] = 'The username is not available.'

  • #4
    New Coder
    Join Date
    Mar 2013
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Need to leave $regnickname empty or else i can't use sticky form for that!

  • #5
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    omg it's just an example...
    Last edited by patryk; 03-28-2013 at 04:24 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •