title: Adding to database. No repeat on refresh
body: <p>I have this code:</p>
  
  <p>Episode.php</p>
  
  <pre><code>    &lt;?$feedback = new feedback;
  $articles = $feedback-&gt;fetch_all();
  
        if (isset($_POST['name'], $_POST['post'])) {
               $cast = $_GET['id'];
               $name = $_POST['name'];
               $email = $_POST['email'];
               $post = nl2br ($_POST['post']);
               $ipaddress = $_SERVER['REMOTE_ADDR'];
  
  if (empty($name) or empty($post)) {
               $error = 'All Fields Are Required!';
  }else{
  $query = $pdo-&gt;prepare('INSERT INTO comments (cast, name, email, post, ipaddress) VALUES(?, ?, ?, ?, ?)');
       $query-&gt;bindValue(1, $cast);
       $query-&gt;bindValue(2, $name);
       $query-&gt;bindValue(3, $email);
       $query-&gt;bindValue(4, $post);
       $query-&gt;bindValue(5, $ipaddress);
  
       $query-&gt;execute();
  } }?&gt;
  &lt;div align="center"&gt;
  &lt;strong&gt;Give us your feedback?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;
  
  &lt;?php if (isset($error)) { ?&gt;
       &lt;small style="color:#aa0000;"&gt;&lt;?php echo $error; ?&gt;&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;?php } ?&gt;
  
  &lt;form action="episode.php?id=&lt;?php echo $data['cast_id']; ?&gt;" method="post" autocomplete="off" enctype="multipart/form-data"&gt;
  &lt;input type="text" name="name" placeholder="Name" /&gt; / &lt;input type="text" name="email" placeholder="Email" /&gt;&lt;small style="color:#aa0000;"&gt;*&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;textarea rows="10" cols="50" name="post" placeholder="Comment"&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;input type="submit" onclick="myFunction()" value="Add Comment" /&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;small style="color:#aa0000;"&gt;* &lt;b&gt;Email will not be displayed publicly&lt;/b&gt;&lt;/small&gt;&lt;br /&gt;
  &lt;/form&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Include.php</p>
  
  <pre><code>class feedback { public function fetch_all(){
      global $pdo;
        $query = $pdo-&gt;prepare("SELECT * FROM comments");
        $query-&gt;bindValue(1, $cast);
        $query-&gt;execute(); return $query-&gt;fetchAll();
                } }
  </code></pre>
  
  <p>This code updates to the database as it is suppose to. But after submission it reloads the current page as mentioned in the form action. </p>
  
  <p>But when I refresh the page to see the comment being added it asks to re submit. If I hit submit then the comment adds again. </p>
  
  <p>How can I stop this from happening?</p>
  
  <p>Maybe I could hide the comment box and display a thank you message but that would not stop a repeat entry. </p>
  
  <p>Please help. Thank you. </p>
  
  <p>Kev</p>