title: Multiple entries into the table on refresh
body: <p>When I submit a form to a PHP_SELF page via POST method, The text get's inserted into the table again on every refresh. How do I fix this and prevent my textarea from being empty before insertion? </p>
  
  <pre><code>echo "&lt;form action=&lt;?php echo $_SERVER['PHP_SELF']; method='post'&gt;";
  echo "&lt;textarea name='msg' placeholder='Type message here' required='required' style='width:100%;min-height:60px;min-height:60px;'&gt;&lt;/textarea&gt;";
  echo "&lt;button&gt;Send&lt;/button&gt;";
  echo "&lt;/form&gt;";
  </code></pre>
  
  <p>And here is my PHP code to insert the text into the table 'msg'.</p>
  
  <pre><code>if(isset($_POST['msg'])&amp;!empty($_POST['msg']))
  {
      $message=$_POST['msg'];
      $message=$conn-&gt;quote($message);
      $sql="INSERT INTO msg(msg.to,msg.from,msg) VALUES('".$_SESSION["tousermessage"]."','".$_SESSION["username"]."',$message)";
      $ex=$conn-&gt;prepare($sql);
      $ex-&gt;execute();
  
      unset($_POST['msg']);
  }
  </code></pre>