Page 1 of 1

Use PHP to create a new page

Posted: Sat Feb 04, 2006 12:15 pm
by wbryan6
Is it possible to use a html form and then have php take that information and create a new html page? If so, does anyone have any experience with this? Thanks.

Posted: Sat Feb 04, 2006 12:34 pm
by tasteslikepurple
that's one of the best things about PHP :)

try this form:

Code: Select all

<form action="page2.php" method="post">
<input type="text" name="firstname">
<input type="submit">
</form>
put this in page2.php

Code: Select all

Hello
<?php

echo $_POST["firstname"];

?>
, welcome to my website.
just a VERY simple example to try.

try looking on google for php form handling or php form processing

Posted: Sat Feb 04, 2006 6:53 pm
by m3mn0n
Um, I think he might have been talking about actually creating a file with html inside it...

If so, take a look at the filesystem functions within the manual.

And a tutorial like this: http://www.onaje.com/php/article.php4/18

Though that is for text file, you can modify it easily for html.

I am wondering though, what were you going to use this ability for?

Posted: Sat Feb 04, 2006 8:25 pm
by wbryan6
I am currently setting up a page to sell electronics online, and I would like to be able to build a page for each item after I have entered it in the database. My current plan is to have the page built through forms and the copy the generated html code and save it as a new file. If the information you have provided will make that process simpler, that would be great. Thanks for the input.

Posted: Sat Feb 04, 2006 8:31 pm
by m3mn0n
More simple? Yes.

Use a single productinfo.php page and then have a variable, such as the product's ID number determine what information is on the page. eg.

productioninfo.php?p=928241

I'd also recommend researching mod_rewrite for more simplistic URLs