Location: PHPKode > projects > MembersGear > membersgear/includes/ctl_isusernameavailable.php
<?php 
require_once("../config/config.php");
require_once(INCLUDE_DIR."/users_class.php");
  
if(isset($_POST))
 {
    
   if(isset($_POST['username'])) 
   {
   
        $origialUser= trim($_POST['username']); 
        $a = trim($_POST['username']);
        $a=trim(strtolower($a));   
        sleep(1);
        $result=false;  
        if($a!='')
        {
 
                
                $users = new users_class();
                $result = $users->IsUserAvailable('select * from '.TABLE_PREFIX.'users where username=? and session_id!=?',array(trim(strtolower(trim($_POST['username']))),session_id()),null);
                
                 if(sizeof($result)>0 && is_array($result))
                 {
                         echo "user_exist";
                         exit;
                          
                  }    
                else
                {
                       $result=true;
                       $username_min_len=MEMBER_LOGIN_MIN_LENGTH;
                       $username_max_len=MEMBER_LOGIN_MAX_LENGTH;
                       $username= $a;
                       $len=strlen($username);
                       //js("alert('".$len."');");

                       if(validate_username_membersGear($username))
                       {
                           //js(alert('here'));
                           if($_POST['from']=="adminrequest")
                           {
                                if($len>=5  && $len <=45)
                                  {  
                                       echo 'yes';
                                       exit;
                                  }
                                else
                                 {
                                      echo 'not_in_length_admin';
                                      exit; 
                                 }
                           }
                          else{
                          
                               if($len>=$username_min_len  && $len <=$username_max_len)
                                  {  
                                       echo 'yes';
                                       exit;
                                  }
                                else
                                 {
                                      echo 'not_in_length';
                                      exit; 
                                 }
                          }         
                                   
                       }
                      else
                       {
                                  echo 'invalid_username';
                                  exit;
                       
                       } 
                     
                }
          
      }
      else
      {
           echo '';
           exit;
           
      }

    }
 }
  
function validate_username_membersGear($username)
{


 if(preg_match('/^[A-Za-z][A-Za-z0-9]*(?:[A-Za-z0-9]+)*$/', $username))
     return true;
 else
    return false;
  
}
?>
Return current item: MembersGear