I created two pages. One is a form (form.php) which asks for input. One of the inputs it asks for is $page_name. After the form is submitted, the variables are sent to template.php which uses those variables to create the template.
At the bottom of the template I added code which copies template.php as temp.php, then copies temp.php into another directory, renames temp.php to $page_name (page.php), and then deletes temp.php. This works, but I also want to make template.php redirect to $page_name.
So what I want to do is enter the page name into the form, submit it, get sent to template and then sent to $page_name. Here is the code:
<?
if ($PHP_SELF=template.php)
{
//use a variable to determine if $page_name already exists in the above directory before temp is renamed to it
// alert me if this page already exists and ask me whether or not to overwrite it
copy ("template.php", "temp.php");
rename ("temp.php", "../$page_name");
unlink ("temp.php");
header("location:../$page_name");
}
?>
Meta refresh makes template.php refresh itself over and over and header isnt working, I just get sent to template.php. Any ideas or suggestions would be greatly appreciated 🙂