The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Create Subdomain With PHP

Discussion in 'General Discussion' started by erictham, Feb 4, 2004.

  1. erictham

    erictham Member

    Jan 3, 2004
    Likes Received:
    Trophy Points:
    I am thinking to make a code to add in my script (addmember.php) so that upon adding of members, it will go to CPANEL and call for the subdomain and redirect link and create the subdomain $ and redirect to

    So far i am only to find out till this part:
    this link allows me to auto login to CPANEL and go to sub domain page.

    Down below is the direct links code to create accounts in WHM


    $url = "http://$hostusername:$hostpassword@$hostdomain:2086/scripts/wwwacct?plan=Custom%20Plan&username=$username&password=$password&msel=$plan1&domain=$domainname$domain";
    $lines_array = file($url);
    while (list ($line_num, $line) = each ($lines_array)) {
    if ($line_num=="43"){
    $result = $line;
    $pos2 = strpos($result, " (");
    $pos1 = strpos($result, "| Ip: ");
    $ip_addr = substr($result, $pos1 + 6, $pos2 - ($pos1 + 6));

    $sql = "SELECT * FROM clients WHERE username='$username' AND domainname='$domainname'";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    $id = $myrow["id"];
    $sql = "UPDATE clients SET ipaddress='$ip_addr' WHERE id=$id";
    $result = mysql_query($sql);

Share This Page