I used PHP to create new pages based off a user input and pre-exisiting "templates" I made (they are not .tpl, i dont think this matters, just clearing it up). Anyways the code runs and creates the files just fine and when I go to view them everything is there but the php includes did not run (and I"m assuming the rest of the php code didn't either). I downloaded the files off the FTP and they are exact copies (besides 2 lines of code that I needed to change based off the user input). Are there permissions or settings is there some code I'm missing to make the PHP run off of these created pages?

Here's the code that makes the pages:
Code:
<?php
	import_request_variables('pg');
	if($send=='send'){		
		include('edited out');
		//Insert data into databases
		$newpage = "$page_link".".php";
		$query = "edited out query";
		mysql_query($query);
		include('includes/random_gen.php');
		$pageid = get_rand_id(10);
		$query2 = "edited out query";
		mysql_query($query2);		
		//create new files
			//create new pages, front end page, back end page
			switch($layout){
				case 1:
					$filename = '../templates/three_cols.php';
					$filename2 = 'templates/three_cols.php';
					break;
				//etc etc truncated to make easier to read
			}
			//open files for reading
			$fh = fopen ($filename, "r") or die ("couldn't open file");
			$fh2 = fopen ($filename2, "r") or die ("couldn't open file");
			//get data from files
			$data = fread($fh,filesize($filename));
			$data2 = fread($fh2,filesize($filename2));
			//close files
			fclose($fh);
			fclose($fh2);
			//new files
			$fh = fopen("../$newpage","w") or die ("couldn't make file");
			$fh2 = fopen("$newpage","w") or die ("couldn't make file2");
			//replace content in the data
			$data = str_replace('0000000000',"$pageid",$data);
			$data2 = str_replace('0000000000',"$pageid",$data2);
			//Proper navigation heading?
			switch($parent_page){
				case 1: //home
					$data = str_replace('<body>','<body id="page1">',$data);
					$data2 = str_replace('<body>','<body id="page1">',$data2);
					break;
				//etc etc...truncated to make it easier to read
			}
			//write the data into the files
			fwrite($fh,$data);
			fwrite($fh2,$data2);
			//close files
			fclose($fh);
			fclose($fh2);			
			//set permissions
			chmod("../$newpage",0644);
			chmod("$newpage",0644);
		//end file creation
		header("Location: $newpage");
		exit(0);
	}
?>
I tried setting permissions to 0755 as well but no luck there.

Any help is greatly appreciated, thanks,
Justin