<?php
if (!isset($_POST['news'])) {
?>
<h1>Add to the News Page</h1>
<table>
<FORM action="add.php" method="POST">
<tr>
<td align=right>Title:</td>
<td><INPUT TYPE="TEXT" name="title"></td>
</tr>
<tr>
<td align=right valign=top>News:</td>
<td><TEXTAREA WRAP=VIRTUAL NAME="news" COLS=50 ROWS=15></TEXTAREA></td>
</tr>
<tr>
<td></td>
<td><INPUT TYPE="SUBMIT" name="submit" value="Submit"></td>
</tr>
</FORM>
</table>
<?php
} else {
$razzzzzz = "
";
$title = $_POST['title'];
$news = $_POST['news'];
$news = str_replace($razzzzzz, '<br>', $news);
$da = getdate();
$date="$da[weekday] $da[mday] $da[month] $da[year]";
$news = ("$title|$date|$news\n");
$file = fopen("news.php", "r");
$read = fread($file, filesize("news.php"));
fclose($file);
$newsfile = fopen("news.php", "w");
$news=stripslashes($news);
fwrite($newsfile, "$news$read");
fclose ($newsfile);
echo "News added";
}
?>