Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Aug 2002
    Posts
    6

    Default Username Exists

    I am slowly converting over my hosting script to use cpanels xmlapi, but I was wondering if it is possible when somebody signs up they are able to check if a username exists. I have been searching for hours with little luck. Might not be seaching for the right thing. Anybody have any ideas or guidance that can be provided.

    Thanks

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by Bytescanada View Post
    I am slowly converting over my hosting script to use cpanels xmlapi, but I was wondering if it is possible when somebody signs up they are able to check if a username exists. I have been searching for hours with little luck. Might not be seaching for the right thing. Anybody have any ideas or guidance that can be provided.

    Thanks
    One way you can do this is search for that user's username using the listaccts function. There's some documentation on how to do this at:

    http://twiki.cpanel.net/twiki/bin/vi...n/ListAccounts

    Alternatively, you could attempt to create the account and when an error comes back indicating the username already exists, prompt your customer for a different username and try again.

  3. #3
    Member
    Join Date
    Aug 2002
    Posts
    6

    Default

    k, thanks cPanelDavidG. Now just to learn Javascript or Ajax to have this work the way I need it to and figure how out to output the xml code.

  4. #4
    Member
    Join Date
    Jul 2003
    Location
    Chester, UK
    Posts
    43
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    This (PHP) function cycles through the existing usernames and comes up with the next unique one, built from the customers first name and surname.

    It returns the username once it's found one.

    Code:
    function workout_user($fname, $sname)
    	{
    		$fname = substr($fname, 0, 4);
    		$lim = 9 - strlen($fname);
    		for($i = 0; $i <= $lim; $i++ )
    		{
    			if (array_key_exists('user', $this->list_accounts('user', $fname . substr($sname, 0, $i))->acct))
    			{
    				continue;
    			}
    			else
    			{
    				return strtolower($fname .  substr($sname, 0, $i));
    				break;
    			}
    		}
    	}
    $this->list_accounts is the result of... '/xml-api/listaccts?searchtype=$arg1&search=$arg2' - $argx are from the function call above. (passed thru simplexml_load_string(); )
    Last edited by stoo2000; 04-25-2009 at 08:03 AM. Reason: added some more information
    SilvesterHost.co.uk

Similar Threads & Tags
Similar threads

  1. Sorry, a mysql user with the name * already exists.
    By ipvhost.ro in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 02-12-2012, 04:43 PM
  2. Replies: 3
    Last Post: 12-20-2010, 06:46 AM
  3. Replies: 2
    Last Post: 02-03-2006, 03:23 PM
  4. Domain already exists?
    By access1 in forum New User Questions
    Replies: 3
    Last Post: 11-07-2005, 04:58 AM
  5. username to username+domain with emails?
    By inov in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 12-28-2003, 06:49 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube