Jump to content

Need help with a simple blog script


mysterio2099

Recommended Posts

Hey guys.. I'm a noob to PHP so I'm not sure if I'm going the wrong direction with this or what, but this is what I'm trying to do.  I'm made a simple blog form with a password to post to a blog page... you know, only one user can post... they know the password, so they can post and tada! It posts to the blog page.  Well... my problem is, I can't get the new blogs to post on TOP of older blogs like a normal blog should...they post at the bottom.  I know this is because of the parameters used with fopen but I can't figure out how to get them to the top.  I tried making a temp variable to hold the information, write the new data, then write the old data under it but I guess I did something wrong because it's not working... and "Resource ID #5" keeps posting under the blog posts, lol. 

Anywho.. here's the code I have as of right now:

[code]
<?php
$pwd = $_POST["password"];
$new_content = "<div><b>" . $date = $_POST["date"] . "</b><br /><br /><i>" . $subject = $_POST["subject"] . "</i><br /><br />" . $blog = $_POST["blog"] . "</div><hr size='1'>";
if (!$old_content = fopen("blog1.php", "a+")) {
header("Location:fileissue.html");
}
else if ($pwd == "password1234") {
$old_content = fopen("blog1.php", "a+");
$tmp_old_content = fopen("blog1.php", "a+");
fwrite($old_content, $new_content);
fwrite($old_content, $tmp_old_content);
fclose($old_content);
fclose($tmp_old_content);
header("Location:postcomplete.html");
}
else {
header("Location:wrongpass.html");
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.