Well, there are a number of ways you can go about this. I would create a header.php file and a footer.php file from the template for inclusion for:
1) When user is creating new page
2) When finished pages are displayed
SO, you have a page with an included header and footer, where there is a form or your text/html editor that they can input their data and click submit to save.
Once, they click submit, you then...
You then have to decide if you want user input (page contents) to be saved to a datase or into a file (.txt, .inc, .htm, .html, .php, etc...).
It didn't sound like you were entertaining the idea of using a db for this, so I thought I would throw it out there as another option.
However, if you want the user to create a file on the server, you have to validate the user input after they submit it: Are there any tags, <script> for instance, that you want to exclude? You need to strip the tags you don't want them to use, etc... and save the validated input into a file. Validation is key! Are their words you won't allow? I wouldn't allow things like "onClick", "execute", etc... So, You may need to replace some strings, then, too. (create arrays of items you wish to exclude and replace them with what you want, or reduce some tags to their htmlentities...) Have I said, validation and cleansing user input is key???
Before the file is written, you have to decide on a structure or pattern for naming and saving the files to the server and where on the server you want to save them. For instance, do you want to name the files using date paramters, do you want to let the users name the files, do you want to create a random code that becomes the file name... This is important, because you will need to know what the file is,when you include it back into the page and display results for the user.
To save the file, you will use fopen(), fwrite(), and fclose(). (Note: If you were going to use a db for this, you would INSERT INTO the database the validated and cleansed input instead.)
After the file is saved, you redirect user to display the results. When you redirect user, you will have to pass a parameter in the query string to identify the specific user and match that request with which page/file you will include and present. (if database is used, you would GET the parameter from the q-string, and use it to query the database, and fetch the results, and finally display the contents column into the page.)
phew.. that should work...
BUt, like I said, there are really a lot of options, so you have to come up with a specific plan and then go about it from point a to point z...