①同じルートに投稿格納場所としての空.txtを用意する。
②formの飛ばし先action=""を自身にする。
<form method="post" action="bbs.php"> <input type="text" name="comment" size="60" /> <input type="submit" value="投稿" /> </form> <?php $bbs_post = file_get_contents('bbs.txt'); // 過去の投稿を読み込む if(@$_POST['comment']){ // 投稿があれば $bbs_post = htmlspecialchars($_POST['comment'])."<hr />$bbs_post"; // 元々あった書き込みの前に最新投稿をくっつける file_put_contents('bbs.txt',$bbs_post); // file_put_contents('どこに',何を);上書きする } echo $bbs_post; ?>