Forum Moderators: coopster

Message Too Old, No Replies

Generate new page with php

         

jgre

11:53 am on Oct 8, 2016 (gmt 0)

5+ Year Member



Hi!

I just want to ask if it is possible to generate a new html file each time user (i.e. admin) makes a new page available through website.
I usually work on a create.php file as the basic file to create new pages. The create.php file contains a form with textarea and input tags.
The form includes action attribute equal to preview.php so I can be able to preview before make the new page available to general public.
Create.php and preview.php located in the same folder which I called /root/members/admin/posts/. These are all I have already done.

And this is what I wan to do next. When I see that the new page is ok I want to publish it with a new file name (i.e. newname), new file extension (i.e. newname.html), and finally, place it under new folder (i.e. /root/members/posts/newname.html).

This is the code of the create.php file:
<form action="/root/members/admin/posts/preview.php" method="post">
<textarea name="title"></textarea>
<textarea name="body"></textarea>
<input type="submit" formtarget="_blank">
</form>


This is the code of preview.php file:
<form action="/root/members/posts/newname.html" method="post">
<?php echo $_POST["title"]; ?>
<?php echo $_POST["body"]; ?>
<input type="submit" name="publish" value="Publish" formtarget="_blank"/>
</form>


I'm not sure if I make it clear so if you need more info about it I may be able to provide. Also note or suggest any other ways that might be better that the one that I'm trying to implement.

Thanks,

mack

11:03 am on Oct 9, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Are you looking to create a fully static html file or a dynamic php page with a re-write for static url's? If you are creating static pages using fopen fwrite may be the answer, although you will need to be fairly creative about how to build the html file. You would need to think of it in terms of a template with a header and footer.... insert header code, insert content then insert footer code.

Mack.

jgre

12:32 pm on Oct 19, 2016 (gmt 0)

5+ Year Member



Hi Mack. Thanks for answering.
Dynamic pages sounds better. However, in any case I will choose the one which provides automation and better control in most cases.
Bur where I stuck is that I want to save the new page under specific folder, with a specific name and in .html extension would be great.
Overwriting url sounds good but involves redirection if I'm not mistaken and I'm not sure if this is good for seo.
John.