Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

Using PHP to create and save a static page?

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

Using PHP to create and save a static page?

Old 11-11-04, 09:38 PM
  #1  
DVD Talk Special Edition
Thread Starter
 
Join Date: Mar 1999
Location: GO BLUE!
Posts: 1,341
Likes: 0
Received 0 Likes on 0 Posts
Using PHP to create and save a static page?

I know that there is a way, but I don't know and cannot find a way to do this.

I have a form that posts to a php script which creates a bio page about my user based on how they filled out the form. Once the php page has been created, I want to then have it save the html as a static file on my server that I nor my users will need to ever update or change anything. Then when anyone comes to my site they can read the bios of the other people each stored on its own page. Can anyone link me a tutorial or something on how to do this?

-BlasTech
Old 11-11-04, 10:28 PM
  #2  
DVD Talk Special Edition
 
Join Date: Sep 2001
Location: Vancouver, Canada
Posts: 1,367
Likes: 0
Received 0 Likes on 0 Posts
Haven't done File IO in PHP in a while, but that's basically what you want. Look up fopen and fwrite. When the user clicks submit, you'll want to have the php file create a new file and write the bio and the surrounding html tags to it.
Old 11-12-04, 12:12 AM
  #3  
DVD Talk Legend
 
Join Date: Jun 2000
Location: NYC
Posts: 17,018
Likes: 0
Received 0 Likes on 0 Posts
http://us2.php.net/manual/en/functio...t-contents.php

The basic structure of the PHP document should be:
Code:
if form submitted
{
     store contents of page to a string
     print string
     create file based on string
}
else show form
Be sure you set the proper permissions on the file if necessary using chmod().

It'd be best to use a database backend like MySQL to store the URLs of the generated documents. I would use usernames for readability, provided they are unique and you won't be changing them. Otherwise just use ID.php or something. Remember, you can write PHP code into a stored page for headers and things.

Last edited by Breakfast with Girls; 11-12-04 at 12:18 AM.
Old 11-12-04, 10:56 AM
  #4  
DVD Talk Gold Edition
 
Join Date: Dec 1999
Posts: 2,708
Likes: 0
Received 0 Likes on 0 Posts
Why can't you store the form information in a dB? This would make accessing the data much easier (plus more scalable in the future). You could then generate each page based upon that user's ID (as Breakfast With Girls mentioned). Even if the page is never going to change, it would be much easier (if you ever did have to change something ) to just make the change once on a template page, than numerous times on each user's saved "bio" page.
Old 11-12-04, 11:17 AM
  #5  
DVD Talk Legend
 
Join Date: Jun 2000
Location: NYC
Posts: 17,018
Likes: 0
Received 0 Likes on 0 Posts
Originally posted by Lampei
Why can't you store the form information in a dB? This would make accessing the data much easier (plus more scalable in the future). You could then generate each page based upon that user's ID (as Breakfast With Girls mentioned). Even if the page is never going to change, it would be much easier (if you ever did have to change something ) to just make the change once on a template page, than numerous times on each user's saved "bio" page.
You're right, a database is definitely the way to go if that is an option. I was just trying to answer the question he asked.

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.