title: PHP/Cpanel - How to create cPanel accounts without 3rd party application?
body: <p>Good evening SO Community,</p>
  
  <p>I've been trying to figure out how to dynamically create a cPanel account with PHP. While doing my pre-question research, I noticed that this question was asked quite a few times, and had a few answers. Unfortunately, the answers that I have found seem to have been depreciated in the latest cPanel versions. I have been trying to get the below script working but had no luck. <strong>NOTE: I DID NOT CREATE THE SCRIPT, I JUST FORGOT THE SOURCE.</strong> If you know of any way to create cPanel accounts with hosting packages, PLEASE let me know!</p>
  
  <pre><code>&lt;?php
  
  ###############################################################
  # cPanel WHM Account Creator 1.1
  ###############################################################
  # Visit http://www.zubrag.com/scripts/ for updates
  ###############################################################
  # Required parameters:
  # - domain - new account domain
  # - user - new account username
  # - password - new account password
  # - package - new account hosting package (plan)
  # - email - contact email
  #
  # Sample run: create-whm-account.php?domain=reseller.com&amp;user=hosting&amp;password=manager&amp;package=unix_500
  #
  # If no parameters passed then input form will be shown to enter data.
  #
  # This script can also be run from another PHP script. This may
  # be helpful if you have some user interface already in place and 
  # want to automatically create WHM accounts from there.
  # In this case you have to setup following variables instead of
  # passing them as parameters:
  # - $user_domain - new account domain
  # - $user_name - new account username
  # - $user_pass - new account password
  # - $user_plan - new account hosting package (plan)
  # - $user_email - contact email
  #
  ###############################################################
  
  ///////  YOUR WHM LOGIN DATA
  $whm_user   = "root";      // reseller username
  $whm_pass   = "PASS";  // the password you use to login to WHM
  
  #####################################################################################
  ##############          END OF SETTINGS. DO NOT EDIT BELOW    #######################
  #####################################################################################
  
  $whm_host   = $_SERVER['HTTP_HOST'];
  
  function getVar($name, $def = '') {
    if (isset($_REQUEST[$name]))
      return $_REQUEST[$name];
    else
      return $def;
  }
  
  // Domain name of new hosting account
  // To create subdomain just pass full subdomain name
  // Example: newuser.zubrag.com
  if (!isset($user_domain)) {
    $user_domain = getVar('domain');
  }
  
  // Username of the new hosting account
  if (!isset($user_name)) {
    $user_name = getVar('user');
  }
  
  // Password for the new hosting account
  if (!isset($user_pass)) {
    $user_pass = getVar('password');
  }
  
  // New hosting account Package
  if (!isset($user_plan)) {
    $user_plan = getVar('package');
  }
  
  // Contact email
  if (!isset($user_email)) {
    $user_email = getVar('email');
  }
  
  // if parameters passed then create account
  if (!empty($user_name)) {
  
    // create account on the cPanel server
    $script = "http://{$whm_user}:{$whm_pass}@{$whm_host}:2086/scripts/wwwacct";
    $params = "?plan={$user_plan}&amp;domain={$user_domain}&amp;username={$user_name}&amp;password={$user_pass}&amp;contactemail={$user_email}";
    $result = file_get_contents($script.$params);
  
    // output result
    echo "RESULT: " . $result;
  }
  // otherwise show input form
  else {
  $frm = &lt;&lt;&lt;EOD
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;cPanel/WHM Account Creator&lt;/title&gt;
    &lt;META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"&gt;
    &lt;META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;style&gt;
      input { border: 1px solid black; }
    &lt;/style&gt;
  &lt;form method="post"&gt;
  &lt;h3&gt;cPanel/WHM Account Creator&lt;/h3&gt;
  &lt;table border="0"&gt;
  &lt;tr&gt;&lt;td&gt;Domain:&lt;/td&gt;&lt;td&gt;&lt;input name="domain" size="30"&gt;&lt;/td&gt;&lt;td&gt;Subdomain or domain, without www&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;&lt;td&gt;&lt;input name="user" size="30"&gt;&lt;/td&gt;&lt;td&gt;Username to be created&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input name="password" size="30"&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Package:&lt;/td&gt;&lt;td&gt;&lt;input name="package" size="30"&gt;&lt;/td&gt;&lt;td&gt;Package (hosting plan) name. Make sure you cpecify existing package&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Contact Email:&lt;/td&gt;&lt;td&gt;&lt;input name="email" size="30"&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan="3"&gt;&lt;br /&gt;&lt;input type="submit" value="Create Account"&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  EOD;
  echo $frm;
  }
  
  ?&gt;
  </code></pre>
  
  <p>Please let me know if you need any more information!</p>
  
  <p>Thank you in advance,
  Tim</p>
  
  <p><strong>EIDT</strong>
  Source: <a href="https://github.com/Ephygtz/cPanel-WHM-automated-account-creator/blob/master/create-whm-account.php" rel="nofollow noreferrer">https://github.com/Ephygtz/cPanel-WHM-automated-account-creator/blob/master/create-whm-account.php</a></p>
  
  <p>Any ideas?</p>