Skip to content


cPanel Account using WHM

This sections will contains code regarding different PHP & MySQL features and contains help about php/mysql issues.

cPanel Account using WHM

Postby Web Guru » February 5th, 2009, 4:44 pm

If you are a hosting company or a WHM (Web Host Manager) account holder, you may want to automate the process of creation of cPanel accounts.

Creating a cPanel account is not a tough task. With the help of the following script, you can create the cpnale account by just passing the WHM Login Info and the Domain related info of the account.

WHM cPanle Account Creation
Code: Select all
<?
   $sWhmUsername = "";    // WHM Account Username
   $sWhmPassword = "";  // WHM Account Password
   $sWhmHost     = "";  // WHM Server Address or IP

   $sDomain   = "";  // Domain Name (without www)
   $sUsername = "";  // cPanel Account Username
   $sPassword = ""; // cPanel Account Password
   $sPackage  = ""; // WHM Hosting Package Name
   $sEmail    = ""; // cPanel Contact Email Address

   $sRequestUrl = "http://{$sWhmUsername}:{$sWhmPassword}@{$sWhmHost}:2086/scripts/wwwacct?plan={$sPackage}&domain={$sDomain}&username={$sUsername}&password={$sPassword}&contactemail={$sEmail}";
   $sResult     = @file_get_contents($sRequestUrl);

   if (@strpos($sResult, "Account Creation Status: ok") !== FALSE)
      print "Hosting Account Created Successfully";

   else
      print ("ERROR: ".$sResult);
?>


With the help of above PHP Code, you can easily create a cpanel account. You can use this script as a standalone or can integrate this into any other script.

If you want to delete an existing cpanel account, you can also do that with the help of the following PHP Code.

WHM cPanel Account Deletion
Code: Select all
   $sWhmUsername = "";    // WHM Account Username
   $sWhmPassword = "";  // WHM Account Password
   $sWhmHost     = "";  // WHM Server Address or IP

   $sUsername = "";  // cPanel Account Username

   $sRequestUrl = "http://{$sWhmUsername}:{$sWhmPassword}@{$sWhmHost}:2086/scripts/killacct?domain={$sUsername}&user={$sUsername}";
   $sResult     = @file_get_contents($sRequestUrl);

   if (@strpos($sResult, "Account Removal Status: ok") !== FALSE)
      print "Hosting Account Deleted Successfully";

   else
      print ("ERROR: ".$sResult);


Both of these PHP Scripts are well tested and found 100% working.
User avatar
Web Guru
 
Posts: 95
Joined: March 24th, 2008, 7:59 am
Location: Lahore, Pakistan

Return to Board index

Return to PHP / MySQL / XML

Who is online

Users browsing this forum: No registered users and 0 guests