title: Clear POST Data Upon Refresh PHP
body: <p>I have a form that re-submits on refresh. I've searched SO and have found nothing relating to my specific issue. I know it is better to have a separate PHP page, but for this specific project it needs to all be on one PHP page. I need the POST to reset when the page is refreshed so the form isn't automatically sent again.</p>
  
  <p>Please note that I CANNOT have the page redirect somewhere else therefore I cannot use Post/Redirect/Get. The outcome I'd like to have is this: Person visits for the first time, enters correct code, script runs, then next time they visit or refresh the page etc, they have to complete the form again. Any suggestions would be much appreciated.</p>
  
  <pre><code>$code = '';
  $hide = "&lt;script&gt;$('form').fadeOut(500).remove();
  $('.wrapper').addClass('form-success');
  $('.container').delay(1800).fadeOut(500);&lt;/script&gt;";
  
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
     $code = secure($_POST["code"]);
  }
  
  function secure($data) {
     $data = trim($data);
     $data = stripslashes($data);
     $data = htmlspecialchars($data);
     return $data;
  }
  
  if (intval($code) == 1234) {
  echo $hide;
  $code = '';
  } else {
  echo "Failed";
  $code = '';
  }
  </code></pre>