hostwiser

Registered
Jul 20, 2013
3
0
1
cPanel Access Level
Root Administrator
Hello,

Greetings to cPanel Team and all the Webmasters.

I was wondering if there is a PHP function available using which I could create an account on cPanel. I googled and tried some scripts but they were of no use.

Regards
 

hostwiser

Registered
Jul 20, 2013
3
0
1
cPanel Access Level
Root Administrator
Hello,

I would go through all the documents carefully but at this moment I need an urgent solution to this. I am looking for a php function using which I would be able to create new accounts based on packages.

Your kind help would be appreciated.

Regards
 

jazz1611

Well-Known Member
Jun 5, 2012
82
0
56
cPanel Access Level
Root Administrator
There is code php create hosting account from me :) Please try it with your website

PHP:
<?php

// Information of WHM (Ex: root)
$whm_user   = "root";    //Username WHM
$whm_pass   = "123456";  //Password WHM
$whm_host   = "123.456.789.123"; //Input Correct Your IP Server

function getVar($name, $def = '') {
  if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
  else
    return $def;
}

// Domain or Subdomain of Hosting
if (!isset($user_domain)) {
  $user_domain = getVar('domain');
}

// Username of Account
if (!isset($user_name)) {
  $user_name = getVar('user');
}

// Passwod of Account
if (!isset($user_pass)) {
  $user_pass = getVar('password');
}

// Name Package
if (!isset($user_plan)) {
  $user_plan = getVar('package');
}

// Email Contact
if (!isset($user_email)) {
  $user_email = getVar('email');
}

// Config for create hosting
if (!empty($user_name)) {

  $script = "http://{$whm_user}:{$whm_pass}@{$whm_host}:2086/scripts/wwwacct";
  $params = "?plan={$user_plan}&domain={$user_domain}&username={$user_name}&password={$user_pass}&contactemail={$user_email}";
  $result = file_get_contents($script.$params);

  // Echo result
  echo "<title>Created Hosting cPanel. Information Hosting Below</title>| Domain: $user_domain<br>
        | Ip: $whm_host<br>
        | UserName: $user_name<br>
        | PassWord: $user_pass<br>
        | Email: $user_email<br>
        | Login cPanel: <a href="http://$whm_host:2082">http://$whm_host:2082</a>";
}
// Box Information Account
else {
$frm = <<<cP
<html>
<head>
  <title>Create Hosting cPanel Easy</title>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>
  <style>
    input { border: 1px solid black; }
  </style>
<form method="post">
<h3>Create Hosting cPanel</h3>
<table border="0">
<tr><td>Domain:</td><td><input autocomplete="off" name="domain" size="30"></td><td>Domain or Subdomain, without www.</td></tr>
<tr><td>Username:</td><td><input autocomplete="off" name="user" size="30"></td><td>Username</td></tr>
<tr><td>Password:</td><td><input autocomplete="off" name="password" size="30"></td><td>Password</td></tr>
<input type="hidden" autocomplete="off" name="package" size="30" value="PackageName"/>
<tr><td>Email:</td><td><input autocomplete="off" name="email" size="30"></td><td></td></tr>
<tr><td colspan="3"><br /><input type="submit" value="Create Hosting"></td></tr>
</table>
</form>
</body>
</html>
cP;
echo $frm;
}
// PackageName change to Hosting1 or Plan1 you created on WHM
$user_domain = $_POST['domain'];
$user_name = $_POST['user'];
$user_pass = $_POST['password'];
$user_email = $_POST['email'];
?>
 

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Hello,

I would go through all the documents carefully but at this moment I need an urgent solution to this. I am looking for a php function using which I would be able to create new accounts based on packages.

Your kind help would be appreciated.

Regards
I'm too curious not to ask, what is the urgent need that you don't have time to review the docs?
 

ilaurens

Active Member
Jul 13, 2013
28
0
1
cPanel Access Level
Root Administrator
Was also thinking that, normally when someone needs to find something urgently, they would use google. It feels like he want us to spoon feed him?
 

hostwiser

Registered
Jul 20, 2013
3
0
1
cPanel Access Level
Root Administrator
Hello,

The urgent need was that I had to create around 500 accounts for a conference demo in our college event.

Thank you for your help. I shall go through these documents and I really appreciate your help and support.

Regards