title: php/mysql comments duplicating automatically on pages reload
body: <p>I have created a commenting system for my website. The problem I have is that, the old comments duplicate themselves anytime the webpage is refreshed or reloaded.
  How can I stop this and only show original comments?
  I have added the entire code here below:</p>
  
  <pre><code>&lt;pre&gt;
  require 'data/connect.php';
  
  
   if(isset($_POST['name'])&amp;&amp; isset($_POST['comment'])){
       $name = trim($_POST['name']);
       $comment = trim($_POST['comment']);
  
       if(!empty($name) &amp;&amp; !empty($comment)){
           $insert = $connect-&gt;query("INSERT INTO 
           comments(name,comment)VALUES('$name','$comment')");
           if($insert){
               echo "Success";
           }else{
               echo "Sorry";
           }
       }
   }
   ?&gt;
   &lt;/pre&gt;
  </code></pre>
  
  <p>form here</p>
  
  <pre><code>&lt;pre&gt;
  &lt;?php 
      if(isset($_POST['name'])&amp;&amp; isset($_POST['comment'])){
          $name = trim($_POST['name']);
          $comment = trim($_POST['comment']);
          if(!empty($name) &amp;&amp; !empty($comment)){
               $query = $connect-&gt;query("SELECT name,comment FROM comments WHERE name='$name' AND comment='$comment'");
              while($row = $query-&gt;fetch_object()){
                  echo "&lt;b&gt;",$row-&gt;name,"&lt;/b&gt;&lt;br/&gt;",$row-&gt;comment;
              } 
          }
      }
     ?&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p>Your help will be appreciated.</p>