Use PHP to create a new page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wbryan6
Forum Newbie
Posts: 22
Joined: Sat Feb 04, 2006 12:13 pm

Use PHP to create a new page

Post 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.
User avatar
tasteslikepurple
Forum Commoner
Posts: 46
Joined: Thu Jan 26, 2006 3:38 am
Location: Bath, UK

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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?
wbryan6
Forum Newbie
Posts: 22
Joined: Sat Feb 04, 2006 12:13 pm

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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
Post Reply