I've just started writing a pretty basic blog to my site that uses just a text file (well, a php file to be accurate, but I treat it like a txt file) to store the information when entered from a certain page, and when you view it from the main page, it just grabs that information and puts it in with the normal webpage. I've got everything working, but i'm having a problem with two things:
1) I cannot figure out how to have it so when I've entered multiple lines into the box for content, they change into multiple paragraphs or a line break in the text file so i'm currently stuck at making one paragraph postings. Apart from writing the paragraph tags myself, is there a way to have the script change it?
I'll give an example of what I mean:
Changing this.
And this.
And this.
to this:
<p>Changing this.</p><p>And this.<br/>And this.</p>
Something along those lines is what I am after. Can it be done?
and 2) I'm stuck when it comes to adding the post to the text file, and having the post add to the start of the file to make it be the 'latest' post. So far, I can only get it to append to the end of the file.
My code for the writing to file:
$posted_qqq = "posts.php";
//WRITE TO POST PAGE
import_request_variables("gP","r_");
$fp = fopen($posted_qqq,"a") or die("Couldn't open $posted_qqq");
flock( $fp, LOCK_EX );
fwrite($fp,"<h1 class=\"title\">".$r_usertitle."</h1><h2 class=\"byline\">Posted by ".$r_username." at ".date("g:ia d/n/Y")."</h2><p class=\"content\">".$r_postcontent."</p>");
flock( $fp, LOCK_UN );
fclose($fp);
Anybody think they could help me with this? :bemused: