title: basename($_SERVER['REQUEST_URI'])) VS $_SERVER['REQUEST_URI']) WITH Header("Location: ")
body: <p>Im attempting to build a simple solution in php to prevent form re-submission on any POST forms on any website where a user may refresh the page after a form has initially been submitted.</p>
  
  <p>Ive come up with the following script:</p>
  
  <pre><code>//STORE POST DATA TO A SESSION  
  if($_POST){
      $_SESSION['reserved']['post'] = $_POST;
      header("Location: " . basename($_SERVER['REQUEST_URI']));
      exit();
  }
  
  //REFILL $_POST
  if(isset($_SESSION['reserved']['post'])){
      $_POST = $_SESSION['reserved']['post'];
      unset($_SESSION['reserved']['post']);
  }
  
  //HANDLE DATA AS USUAL...
  if($_POST){
      echo $_POST['firstname'];
  }
  </code></pre>
  
  <p>Locally testing a project my current URL is 
  <a href="http://localhost/system/CustomersV2/account.php?action=register" rel="nofollow noreferrer">http://localhost/system/CustomersV2/account.php?action=register</a></p>
  
  <p>My question relates to line 4 of the script.</p>
  
  <p>Which is a more widely accepted/compatible method of redirecting a page to itsself irregardless of webhost or web browser?</p>
  
  <pre><code>//redirect to 'account.php?action=register'
  header("Location: " . basename($_SERVER['REQUEST_URI']));
  </code></pre>
  
  <p>or</p>
  
  <pre><code>//redirects to '/system/CustomersV2/account.php?action=register'
  header("Location: " . $_SERVER['REQUEST_URI']);
  </code></pre>
  
  <p>Or does it really not matter? (Any other suggestions regarding this script are also very much welcomed)</p>