View Full Version : PhP to static HTML?
02-04-2003, 06:05 PM
I would like to design a site so that a few internal people can update a news database and then use php to publish the reports to static html pages that the public will access.
This approach would be good because the news reports, once published wouldn't be changed much and would not need php phrasing on each hit. If they were I would have them re-published.
Anyway my question is this.
How would I make a php script that would output the data of the news page to a static html page?
I understand how to access a mysql database.
What I don't know is how to redirect the output of a php script to a static file instead of sending it to a browser.
[edit to add system info]
I am using:
OS Windows xp and 2k (dev and production systems)
Apachie webserver new ver (downloaded 2months ago, i forget the ver)
Thanks in advance!
02-04-2003, 09:22 PM
If you really intend to use static html, which on high-traffic site surely can make sense, you have no other option than to rewrite the file. That means that the output of your database query is not printed or echoed, but rather stored in a variable and this variable's content written to a textfile.
You will have to first read the textfile and somehow define where to start the news content and where to end it. That should leave you with three areas: One with the HTML source before the news content, the news content and the HTML source coming after the news area. Now you save all those areas sequentially to the file again.
If that sounds like being tedious task for a complicated site where you have to change content at varying positions, it might well be so. IMO a PHP-driven page makes much more sense for a site that does not have high traffic, and if you're concerned about performance, you could optimize later. But it depends on your individual setup of server, database etc.
02-04-2003, 10:54 PM
To be very honest, my true concern is security. Being new to PhP I understand that there are allot of security issues to consider before using php on a public facing site. Not that php is insecure, I just don't fully understand all the 'best practices' of coding a public facing web app just yet.
So in order to baby step my way into putting content on a public facing site, I wanted to first find a way to use php in a private site, and just push the results in static form onto the public facing site.
At the very least I can put off worrying about opening huge security holes, by not coding a php app on the public site just yet.
02-05-2003, 01:50 AM
I don't really understand you security concerns. Are you developing an application to be used in an intranet environment, or is it rather a web-frontend only to be used by certain trusted people? Somewhre you have to employ a PHP script that runs on the server which is open to the public, because you have to save the file there. Well, alternatively, you could FTP it to the "public" site with PHP's FTP functions.
Most security issues arise from malicious user input that is not validated thoroughly before further processing. However, your post indicates that you came across some of these issues while on research, but you seem to have had problems understanding them. If that's the case, just tell us which and we try to explain them as good as we can.
I guess you came across this?
Security Issues in PHP? :rolleyes: :D
Now, the PHP just outputs html, except make sure that each line is like
document.write("New article 1 blah blah blah");
If you want dynamic content with static pages, It is a big ask.
You need to use a dynamic method, So really, you have to get PHP to do some work..
The only other way I can think of is to get PHP to re-write the static page every time someone updates the database. Which can be done, but then you need to implement a template system..
btw, if security is the issue, you better stop worrying. Hundreds of thousands of websites run on PHP.. unless your getting over 10,000 hosts per day, I doubt there is anything to worry about...
This forum is made in PHP... and most forums these days are. UBB (CGI Forum) is probably dieing very fast. phpBB, vB and few others have already taken over...
Hope it helps
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.