Php: Writing To An Html File.
- Alexander
-
Alexander
- Member since: Jul. 5, 2006
- Offline.
-
- Forum Stats
- Moderator
- Level 11
- Writer
Hi guys,
I'm redesigning my website and I want it to include a posting section (Along the style of a *chan).
I was wondering if there are words for when a PHP file writes to the top of an HTML file, and if you could point me towards a good tutorial?
I'll try to clarify it a little better.
A user inputs into a text box and presses submit > Sends the information to the php file and the php file writes it to the top of an HTML file, but not neccicarily the very top.
Basically I'm asking if there is a way to write text to an html file in a specific place via PHP.
Can anyone help?
- smulse
-
smulse
- Member since: Mar. 24, 2005
- Offline.
-
- Forum Stats
- Member
- Level 31
- Blank Slate
Is there a reason it has to write to a HTML file?
Why not write to a blank file and include that in your page? Surely just overwriting data in a file is going to be a lot easier than trying to find a certain line of code in a HTML document, editing it whilst keeping everything else in place, etc. Then just doing something like <?php include("updates.php"); ?> where you require.
I don't know, just seems like you're over complicating things.
- Alexander
-
Alexander
- Member since: Jul. 5, 2006
- Offline.
-
- Forum Stats
- Moderator
- Level 11
- Writer
At 7/24/11 12:56 PM, smulse wrote: Is there a reason it has to write to a HTML file?
Why not write to a blank file and include that in your page? Surely just overwriting data in a file is going to be a lot easier than trying to find a certain line of code in a HTML document, editing it whilst keeping everything else in place, etc. Then just doing something like <?php include("updates.php"); ?> where you require.
I don't know, just seems like you're over complicating things.
Hmmm. That would probably be easier.
And that could be easier, but I feel like that would mean creating a text file and storing it on the server for every post and comment.
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
At 7/24/11 01:03 PM, Alexander wrote: And that could be easier, but I feel like that would mean creating a text file and storing it on the server for every post and comment.
That would be a lot easier than writing to an HTML file. You don't even have to store it in your home directory; you could store it where a web browser could not access it (i.e. /home/private/ rather than /home/public_html/ for instance). And you wouldn't need multiple text files, just one, and on each new comment, append the new comment to the end of the text file.
Then on your HTML page (which will have to become a php page), use PHP to get the information from the text file.
Anyway, that's how I would do it without databases :$
- lucatheawsome
-
lucatheawsome
- Member since: Mar. 2, 2009
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
just use this futtallby its pre made chan software
oh and btw i would not advise hosting a chan unless you can moderte it 24 hours aday
- Alexander
-
Alexander
- Member since: Jul. 5, 2006
- Offline.
-
- Forum Stats
- Moderator
- Level 11
- Writer
At 7/24/11 11:56 PM, lucatheawsome wrote: just use this futtallby its pre made chan software
oh and btw i would not advise hosting a chan unless you can moderte it 24 hours aday
Haha, well it's not a full on chan, but in the style of one. But thank you! This is going to help!


