I'm currently trying to get a part of an admin system setup whereby I can create a new sub directory on a domain, I have that part working however, I'm having issues putting a .php template into the directory once it has been created.
Here is the code I'm using to create the directory itself on the server:
Like i say, the directory creation is working perfectly, but when it comes to adding the following code to upload an index.php file into the 'new' directory, nothing is happening:
The index.php file is basically a templated layout that will read the directory name, in addition to some random array stuff to generate a bunch of text while also pulling a list of data from my database to display on the index page of the new directory.
Could someone with a little more knowledge take a moment to point me in the right direction on how I get the new page creation to work please?
Im not getting any error logs when the button on the submit form is clicked
Here is the code I'm using to create the directory itself on the server:
<?php
function createDirectory() {
$add = $_POST["add"];
mkdir("/blah/blah/domain.com/toplevel".$add);
echo "<script type = 'text/javascript'>alert('Done!');</script>";
}
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<title>
Create directory
</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action = "" method = "post">
<table>
<tr>
<td style = " border-style: none;"></td>
<td bgcolor = "blue" style = "font-weight: bold">
Directory Name
</td>
<td bgcolor = "red">
<input type = "text" style = "width: 220px;"
class = "form-control" name = "add" id = "add" />
</td>
<td bgcolor = "blue" colspan = "2">
<input type = "submit" name = "submit"
value = "Create directory" />
</td>
</tr>
</table>
</form>
<?php
}
else {
createDirectory();
}
?>
</body>
</html>
function createDirectory() {
$add = $_POST["add"];
mkdir("/blah/blah/domain.com/toplevel".$add);
echo "<script type = 'text/javascript'>alert('Done!');</script>";
}
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<title>
Create directory
</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action = "" method = "post">
<table>
<tr>
<td style = " border-style: none;"></td>
<td bgcolor = "blue" style = "font-weight: bold">
Directory Name
</td>
<td bgcolor = "red">
<input type = "text" style = "width: 220px;"
class = "form-control" name = "add" id = "add" />
</td>
<td bgcolor = "blue" colspan = "2">
<input type = "submit" name = "submit"
value = "Create directory" />
</td>
</tr>
</table>
</form>
<?php
}
else {
createDirectory();
}
?>
</body>
</html>
$my_file = 'index.php';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
Could someone with a little more knowledge take a moment to point me in the right direction on how I get the new page creation to work please?
Im not getting any error logs when the button on the submit form is clicked


Comment