If I use the mode "r+" for fopen, it places the pointer at the beginning of the file, but it over-writes everyting. I need to place text at the beginning of the file (by placing the pointer there), but the text following it must move down (reflow in browser terms).
Here is the main file. It includes a stylesheet (which is not important) and a file pass.php (which simply defines $setpass as the correct password).
Code: Select all
<?php
//By Nilson Cain//
//For posting to the blog//
//Require Authentication//
require('./pass.php');
$pass = $_POST['pass'];
$title = $_POST['title'];
$message = $_POST['message'];
if($pass != $setpass || !$pass)
{
$title="";
$message="";
print <<<END
<html><head><link rel="stylesheet" type="text/css" href="main.css" /></head><body>
<form action="post.php" method="post">
Password: <input type="password" name="pass" size="20" /><br/>
<input type="submit" value="OK" /><br/>
</form>
</body></html>
END;
}
else if($pass = $setpass)
{
print <<<END
<html><head><link rel="stylesheet" type="text/css" href="main.css" /></head><body>
<form action="post.php" method="post">
<input type="hidden" name="pass" value="$pass" />
Title: <input type="text" size="20" name="title" /><br/>
Blog: <textarea name="message" rows="8" cols="30"></textarea><br/>
<input type="submit" value="OK">
</body></html>
END;
}
else{
echo "ERROR";
}
if($pass = $setpass && $title && $message)
{
$filename = 'posts.txt';
$open = fopen ($filename, "a");
$dateid=date("Fd");
$fulldate=date("l, F d, Y");
$content = "<div class=\"header\"><span class=\"title\">$title</span><span class=\"date\" id=\"$dateid\">$fulldate</span></div>\n<p>$message</p>\n";
fwrite($open, $content);
}
?>
I know that the code is very simplistic as of right now (features to come later) but does anyone know any way to solve my problem? Thanks
BTW, the site that this is for is located @ http://nilsonscorner.dyndns.org/.