i've already tried that but it didn't seam to do the trick. Below is the code which I currently have.
<?php
include '/home/jon1984/public_html/central_methodist_church/includes/database.php';
include '/home/jon1984/public_html/central_methodist_church/includes/header.php';
include '/home/jon1984/public_html/central_methodist_church/includes/menu.php';
include '/home/jon1984/public_html/central_methodist_church/includes/footer.php';
echo $header;
echo $dynamic_menu;
echo $menu;
if(isset($POST["filename"]))
{
$filename = $POST["filename"];
$extension = ".php";
$file = $filename.$extension;
$content = $POST["content"];
$submenu_id = $POST["content_category"];
$content_heading = $POST["content_heading"];
$content_subheading = $POST["content_subheading"];
$content_status = $POST["content_status"];
$SESSION['page_name'] = $file;
$heading = <<<HEADING
<h1>$content_heading</h1>
HEADING;
$subheading = <<<SUBHEADING
<h2>$content_subheading</h2>
SUBHEADING;
$content_structure = <<<STRUCTURE
<p>$content</p>
STRUCTURE;
$file_location = "/home/jon1984/public_html/central_methodist_church/cms/$file";
$new_location = "/home/jon1984/public_html/central_methodist_church/$file";
if(file_exists($filename))
{
echo $filename . " already exists";
}
else
{
$sql = "INSERT INTO my_menu (menu_name,submenu_id) VALUES('$content_subheading','$submenu_id')";
$result = mysql_query($sql);
$sql2 = "INSERT INTO my_content (filename,content,content_status,content_heading,content_subheading,date_added) VALUES('$file','$content','$content_status','$content_heading','$content_subheading',now())";
$result2 = mysql_query($sql2);
$fp = fopen($file, "w") or die ("Couldn't open $file");
fwrite($fp,$header . $dynamic_menu . $menu . $heading . $subheading . $content_structure . $footer);
fclose($fp);
echo "The following page has been created " . $file;
echo "<br />";
copy($file_location, $new_location);
echo "The page has been moved to the following location : " . $new_location;
echo "<br />";
unlink($file);
echo "The page has been deleted from the temporary location";
}
}
else
{
$form = <<<FORM
<form name="add_content" action="add_content.php" method="post" />
<label for="filename">filename</label>
<input type="text" name="filename" /><br />
<label for="content_category">content category</label>
<select name="content_category">
FORM;
$sql = "SELECT * FROM my_menu WHERE submenu_id = 0";
$result = mysql_query($sql);
while($row=mysql_fetch_assoc($result))
{
$menu_name = $row['menu_name'];
$menu_id = $row['menu_id'];
$form .= <<<FORM
<option value=$menu_id>$menu_name</option>
FORM;
}
$form .= <<<FORM
</select><br />
<label for="content_heading">content heading</label>
<input type="text" name="content_heading" /><br />
<label for="content_subheading">content subheading</label>
<input type="text" name="content_subheading" /><br />
<label for="content_status">content status</label>
<select name="content_status">
<option value="draft">draft</option>
<option value="live" selected="selected">live </option>
</select><br />
<label for="content">content</label>
<textarea name="content" cols="50" rows="5"></textarea><br />
<input type="submit" value="add content" />
</form>
FORM;
echo $form;
}
echo $footer;
?>