title: how to prevent f5 resubmitting php page
body: <p>how to prevent f5 resubmitting php page?</p>
  
  <p>i very tired,</p>
  
  <p>i want prevent f5 !</p>
  
  <p>i tried very much of solutions</p>
  
  <p>but all solutions is invalid!</p>
  
  <p>please help me</p>
  
  <p>i tried header('Location: index.php'); but not working!</p>
  
  <p>if you can help me, please edit my php code and paste your code..</p>
  
  <p>My form code in index.php file:</p>
  
  <pre><code>&lt;form id="uploadedfile" enctype="multipart/form-data" action="upload.php" method="POST"&gt;
  &lt;input name="uploadedfile" type="file" /&gt;
  &lt;input type="submit" value="upload" id="submit" name="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My php code in upload.php file:</p>
  
  <pre><code>&lt;?php
  $allowedExts = array("gif", "jpeg", "jpg", "png", "zip", "pdf", "docx", "rar", "txt", "doc");
  $temp = explode(".", $_FILES["uploadedfile"]["name"]);
  $extension = end($temp);
  $newname = $extension.'_'.substr(str_shuffle(str_repeat("0123456789abcdefghijklmnopqrstuvwxyz", 7)), 4, 7);
  $imglink = 'imgs/file_';
  $uploaded = $imglink .$newname.'.'.$extension;
  if(isset($_FILES["uploadedfile"])){
  header('Location: index.php'); 
  if ((($_FILES["uploadedfile"]["type"] == "image/jpeg")
  || ($_FILES["uploadedfile"]["type"] == "image/jpeg")
  || ($_FILES["uploadedfile"]["type"] == "image/jpg")
  || ($_FILES["uploadedfile"]["type"] == "image/pjpeg")
  || ($_FILES["uploadedfile"]["type"] == "image/x-png")
  || ($_FILES["uploadedfile"]["type"] == "image/gif")
  || ($_FILES["uploadedfile"]["type"] == "image/png")
  || ($_FILES["uploadedfile"]["type"] == "application/msword")
  || ($_FILES["uploadedfile"]["type"] == "text/plain")
  || ($_FILES["uploadedfile"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
  || ($_FILES["uploadedfile"]["type"] == "application/pdf")
  || ($_FILES["uploadedfile"]["type"] == "application/x-rar-compressed")
  || ($_FILES["uploadedfile"]["type"] == "application/x-zip-compressed")
  || ($_FILES["uploadedfile"]["type"] == "application/zip")
  || ($_FILES["uploadedfile"]["type"] == "multipart/x-zip")
  || ($_FILES["uploadedfile"]["type"] == "application/x-compressed")
  || ($_FILES["uploadedfile"]["type"] == "application/octet-stream"))
  &amp;&amp; ($_FILES["uploadedfile"]["size"] &lt; 5242880) // Max size is 5MB
  &amp;&amp; in_array($extension, $allowedExts))
  {   
  move_uploaded_file($_FILES["uploadedfile"]["tmp_name"],
  $uploaded );
  include 'upload.html';
  }
  if($_FILES["uploadedfile"]["error"] &gt; 0){
  echo '&lt;h3&gt;Please choose file to upload it!&lt;/h3&gt;'; // If you don't choose file
  }
  elseif(!in_array($extension, $allowedExts)){
  echo '&lt;h3&gt;This extension is not allowed!&lt;/h3&gt;'; // If you choose file not allowed
  }
  elseif($_FILES["uploadedfile"]["size"] &gt; 5242880){
  echo "Big size!"; // If you choose big file
  }
  }
  ?&gt;
  </code></pre>
  
  <p>Thanks.</p>