<!doctype html>
<html>
<body>
<form action="/" method="POST">
Post Comment: <br>
<input type="text" style="width: 300px;" name="comment">
<input type="submit">
</form>
<br>
<?php
if(isset($_POST["comment"]))
{
$comment = $_POST["comment"];
if(file_exists("comments.txt"))
{
$comments = file_get_contents("comments.txt");
$comments = $comments . $comment;
file_put_contents("comments.txt", $comments);
echo htmlentities(file_get_contents("comments.txt"));
}
else
{
file_put_contents("comments.txt", $comment);
echo htmlentities(file_get_contents("comments.txt"));
}
}
?>
</body>
</html>