I am creating a mini system to create a folder with files inside. but I want the files to have the html and php code inside when it's created.
The problem is that I can not find information to help me? Could someone help me?
Code:
<?php
$dirname = $_POST["name"];
$filename = "{$dirname}";
if (file_exists($filename)) {
echo "El nombre de usuario {$dirname} Ya existe";
} else {
mkdir("users/{$dirname}", 0777);
$content = "Nombre:".$_POST["name"]." Direccion:".$_POST["address"];
$fp = fopen("users/{$dirname}/index.php", "w");
$fp = fopen("users/{$dirname}/archivo.php", "w");
$fp = fopen("users/{$dirname}/configuracion.php", "w");
$fp = fopen("users/{$dirname}/configuracion_cambiar.php", "w");
$fp = fopen("users/{$dirname}/configuracion_eliminararchivos.php", "w");
$fp = fopen("users/{$dirname}/configuracion_fotoperfil.php", "w");
$fp = fopen("users/{$dirname}/eliminararchivos.php", "w");
$fp = fopen("users/{$dirname}/eliminarcuenta.php", "w");
$fp = fopen("users/{$dirname}/eliminarfoto.php", "w");
$fp = fopen("users/{$dirname}/enviado.php", "w");
$fp = fopen("users/{$dirname}/login.php", "w");
$fp = fopen("users/{$dirname}/panel.php", "w");
$fp = fopen("users/{$dirname}/perfilcorrecto.php", "w");
$fp = fopen("users/{$dirname}/salir.php", "w");
$fp = fopen("users/{$dirname}/subir", "w");
$fp = fopen("users/{$dirname}/validar.php", "w");
fwrite($fp,$content);
fclose($fp);
echo "Tu cuenta {$dirname} Fue creado correctamente.";
}
?>
<?php
$fp = fopen("{users/$dirname}/index.php", "w") or die("Error al intentar abrir el archivo!");
$txt = "test\n";
fwrite($fp, $txt);
fclose($fp);
?>