<?php
$dirPath = $_POST['username'];
$dirPass = $_POST['password'];
if (file_exists($dirPath)) {
echo("Not available");
} else {
if (isset($_REQUEST['sav']))
{
header('Location: http://example.com/'.$dirPath);
}
$result = mkdir($dirPath, 0755);
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else
{
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
// Source directory (can be an FTP address)
$src = "copy/";
// Full path to the destination directory
$dst = "$dirPath/";
recurse_copy($src,$dst);
}
?>
Above shows the code that I am following. There is a form with an input field, when the user types something into that input and hits submit, a new directory will be created called 'Whatever he entered in the input' and it will contain all the files from an existing directory called 'Copy'.
This works perfectly. Lets say the user enters 'Example' and hits submit, he would have to go to http://example.com/Example.
How would I make it so that when the new directory is created, the user would have to go to a subdomain to access it. http://Example.example.com instead of http://example.com/Example.