Sigh, I had to really rewrite it:
<?php
if (isset($_POST["name"], $_POST["text"])) {
$contents = strip_tags($_POST["name"]) . ' : '
. strip_tags($_POST["text"]) . "\n";
if (file_put_contents("comments.db", $contents, FILE_APPEND) === false) {
die("Robbit Shout is down, try again later.");
}
echo $contents;
} else {
echo file_get_contents("comments.db");
}
?>
My reasoning is that you probably want to print the contents of the file even if the name is provided but the text is not. Then, there is no point reading from the file right after you have written to it.
EDIT:
Oh wait, that is wrong, since you are appending. As such, it should be:
<?php
if (isset($_POST["name"], $_POST["text"])) {
$contents = strip_tags($_POST["name"]) . ' : '
. strip_tags($_POST["text"]) . "\n";
if (file_put_contents("comments.db", $contents, FILE_APPEND) === false) {
die("Robbit Shout is down, try again later.");
}
}
echo file_get_contents("comments.db");
?>