I have a single page comment php web page that writes comments to a file. But on refresh it keeps reposting last comments. How do code it to only write to the file only if submit button pressed. Thank you.
<?php
    /*if($_POST)*/
    if(isset($_POST['submit_btn'])) {
        $name = $_POST['name'];
        $comment = $_POST['comment'];
        $handle = fopen("comments.php", "a");
        fwrite($handle, "<div><b><i>" . $name . "</b></i> update:<br>" . $comment . "<br></div><br>" );
        fclose($handle);
    }
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Rolling Log</title>
        <meta charset="uft-8">
    </head>
    <style>
        body {
          background-color: grey;
        }
        #top,#bottom {
          margin: 0 auto;
          width: 50%;
          padding: 5px;
        }
        div {
          border: 1px solid black;
          background-color: white;
        }
    </style>
    <body>
        <div id="top">
            <h1>Post a change mgmt comment</h1>
            <form action="" method="POST">
                Name: <br /> <input type="text" name="name"> <br />
                Comment: <br /> <textarea rows="5" cols="70" name="comment"></textarea> <br /><br />
                <input type="submit" name="submit_btn" value="Post comment">
            </form>
        </div>
        <br>
        <div id="bottom">
            <h1>Other CM Comments</h1>
            <?php include "comments.php"; ?>
        </div>
    </body>
</html>