I'd like to write a few lines to a template file on my server from my php webpage and then download a copy of it.
I'll use main.php that contains the form to be filled. It has input fields for changeme1 and changeme2.
I'll use create.php that will read in the POSTed details from main.php and write them out to template.php which is structured as below (but much larger and complex):
<html>
<head>
<title>Test1</title>
</head>
<body>
<p>{changeme1}</p>
<p>{changeme2}</p>
</body>
</html>
Is there a way I can read this template.php in, make the mods to {changeme1} and {changeme2} and write back out to a downloadable file? I'm thinking search and replace perhaps?
I have already managed to get the download of a file via headers working using other info found on SO here: PHP create file for download without saving on server
but this method echoes the html stuff where I need to simply write where the curly brackets are. Because of the final size of template.php echoing would not be suitable as it would mean a lot of work after every template change, modifying the template suitable for php echoing (hope you understand me here).
Thanks in advance.