missing the obvious?
Posted: Sun Oct 02, 2005 10:11 pm
Hi,
I am almost done with a script I am writing but am hung up on the last part.
Here's the process I would like to see happen:
User fills out a form, hits send:
My main script processes the information.
I then want the main script to take an already existing HTML file and open it for reading....replace several variables thourghout, and then save the file in another location.
The existing HTML is actually a PHP. Here is an example of it:
<HTML><HEAD><TITLE>Blah</TITLE></HEAD><BODY>
<P>Firstname: <?php echo $firstname; ?>
</BODY>
</HTML>
I want that file to be opened, all the variables/php code replaced with the variables that were passed to the main script. And I want the main script to save the HTML with the variables replaced to another location.
I tried:
$content = include(/home/user/templates/template.php);
I also tried
$contents = file_get_contents("http://domain.com/templates/template.ph ... $firstname);
Their is actually alot more variables (about 10 total) that I want passed to the other script. I don't care what way it is done, I just want to open a file, replace the variables, and save the file in another location as a .html file.
I already know how to open a file for writing, that is no problem. I just need to find a way to load the template, process the php, and store the output in a string variable. Then I will be able to write that string to a new file.
Thanks
I am almost done with a script I am writing but am hung up on the last part.
Here's the process I would like to see happen:
User fills out a form, hits send:
My main script processes the information.
I then want the main script to take an already existing HTML file and open it for reading....replace several variables thourghout, and then save the file in another location.
The existing HTML is actually a PHP. Here is an example of it:
<HTML><HEAD><TITLE>Blah</TITLE></HEAD><BODY>
<P>Firstname: <?php echo $firstname; ?>
</BODY>
</HTML>
I want that file to be opened, all the variables/php code replaced with the variables that were passed to the main script. And I want the main script to save the HTML with the variables replaced to another location.
I tried:
$content = include(/home/user/templates/template.php);
I also tried
$contents = file_get_contents("http://domain.com/templates/template.ph ... $firstname);
Their is actually alot more variables (about 10 total) that I want passed to the other script. I don't care what way it is done, I just want to open a file, replace the variables, and save the file in another location as a .html file.
I already know how to open a file for writing, that is no problem. I just need to find a way to load the template, process the php, and store the output in a string variable. Then I will be able to write that string to a new file.
Thanks