How will you create sub domains without manually creating it from Control Panel? Sub Domains must me created by using PHP script for a membership website. Answer with a sample script.
Total Answers and Comments: 4
Last Update: September 06, 2008 Asked by: thunderman
* Create the appropriate web root directory, for example /home/sites/username/web , and any subdirectories you wish * Edit httpd.conf - add a new virtual host section * Restart httpd
In a normal Linux server setup, php/Apache does not have the necessary permissions to do all this.
use this script to add new subdoamin in your cpanel account
subdomainform.php
<html> <head> <title>create a subdomain</title> </head> <body> <form name="form1" method="post" action="addsubdomain.php"> <h1>create Sub Domains</h1> Sub Domain Name : <input type="text" name="subdomain"><br /> <input type="submit" name="Submit" value="Submit"> </form> </body> </html>
==============================
addsubdomain.php =============================
<?php
ini_set('display_errors', 1);
$host = "domainname.com"; // your domain name without the www $port = 2082; $path = "/frontend/x/subdomain/doadddomain.html?domain=".$_POST['subdomain']."&rootdomain=".$host; //or .dll, etc. for authnet, etc.
// these lines are changed $cpaneluser = "username"; $cpanelpass = "pass"; $authstr = "$cpaneluser:$cpanelpass"; //****************************
// Setup the Auth String $pass = base64_encode($authstr);
//************************************* // Remove this to stop it from displaying the output fron the CPanel //************************************* //loop through the response from the server /* while(!feof($fp)) { echo fgets($fp, 4096); }
*/ while(!feof($fp)) { fgets($fp, 4096); } //close fp - we are done with it fclose($fp); }