title: How to return to file upload page after successful upload?
body: <p>I have a form for file upload and its working no problems.
  The problem comes when I wish to return to the form after the file upload is complete. The form will not show. I read another post on here that said that i need to use </p>
  
  <pre><code>header("Location: upload.php?message=" . $message . "");
  </code></pre>
  
  <p>and so did, however the from is still not showing. What can i do to make this work?</p>
  
  <p><strong>upload.php:</strong></p>
  
  <pre><code>    &lt;?php
      session_start();
      $servername = "localhost";
      $username = "***********";
      $password = "*********";
      $dbname = "**********";
  
      // Create connection
      $conn = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn-&gt;connect_error) {
          die("Connection failed: " . $conn-&gt;connect_error);
        }
      ?&gt;
      &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
        &lt;link rel="stylesheet" type="text/css" href="main.css"&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
        &lt;title&gt;Untitled Document&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
        &lt;div class="container"&gt;
          &lt;div class="nav"&gt;
       &lt;/div&gt;
       &lt;div class="main"&gt;
       &lt;div class="content update"&gt;
         &lt;?php
           if($_SESSION["logedin"] == "true"){
             $sql = "SELECT * FROM content WHERE ID=" . $_POST["ID"];
             //echo $sql;
             $result = $conn-&gt;query($sql);
             while($row = $result-&gt;fetch_assoc()) { 
               $title=$row["title"];
               $body=$row["body"];
               $id=$row["ID"];
             }
           }
           $breaks = array("&lt;br /&gt;","&lt;br&gt;","&lt;br/&gt;","&lt;br /&gt;","&amp;lt;br /&amp;gt;","&amp;lt;br/&amp;gt;","&amp;lt;br&amp;gt;");
           //$title = str_ireplace($breaks, "\n", $title);
           //$body = str_ireplace($breaks, "\n", $body);  
           //echo $body;
           echo $_GET['message'];
      ?&gt;
  
      &lt;form action="doupload.php" method="post" enctype="multipart/form-data"&gt;
        Name file:
        &lt;input type"text" name="title"&gt;
        Select file to upload:
        &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt;
        &lt;input type="hidden" name="doload" value="doload"&gt;
        &lt;input type="submit" value="Upload" name="submit"&gt;
      &lt;/form&gt;
      &lt;/div&gt;
      &lt;div class="row2"&gt;
        &lt;h2&gt;&lt;/h2&gt;
        &lt;/div&gt;
         &lt;div class="row2"&gt;
           &lt;div class="contentbubble"&gt;
             &lt;h2 id="demo"&gt;&lt;/h2&gt;
             &lt;p id="demo2"&gt;&lt;/p&gt;
           &lt;/div&gt;
         &lt;/div&gt; 
      &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p><strong>doupload.php</strong></p>
  
  <pre><code>    &lt;?php
       session_start();
        $message="";
        $filename = 'forms/';
        if (file_exists($filename)) {
            //echo "The file $filename exists";
          } else {
            //echo "The file $filename does not exist";
          }
  
        $servername = "localhost";
        $username = "**********";
        $password = "**********";
        $dbname = "***********";
  
        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn-&gt;connect_error) {
               die("Connection failed: " . $conn-&gt;connect_error);
          }
  
  
        if($_POST["doload"]=="doload"){
          $target_dir = "forms/";
          $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
          //echo "File Name:" . $target_file . "&lt;br&gt;";
          $uploadOk = 1;
          $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  
          // Check if file already exists
          if (file_exists($target_file)) {
               $message="Sorry, file already exists.&lt;br&gt;";
               $uploadOk = 0;
            }
          // Check file size
          if ($_FILES["fileToUpload"]["size"] &gt; 500000) {
              $message="Sorry, your file is too large. &lt;br&gt;";
              $uploadOk = 0;
          }
          // Allow certain file formats
          if($imageFileType != "jpg" &amp;&amp; $imageFileType != "png" &amp;&amp; $imageFileType != "jpeg" &amp;&amp; $imageFileType != "gif" &amp;&amp; $imageFileType != "pdf" ) {
              $message= "Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.&lt;br&gt;";
              $uploadOk = 0;
          }
          // Check if $uploadOk is set to 0 by an error
          if ($uploadOk == 0) {
              $message= $message . "Sorry, your file was not uploaded.&lt;br&gt;";
          // if everything is ok, try to upload file
          } else {
              if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
                  $message = "The file " . basename( $_FILES["fileToUpload"]["name"]). " has been uploaded. &lt;br&gt;";
          //echo $message;
          $title=$_POST['title'];
  
          $sql = "INSERT INTO forms (Name, Path)
          VALUES ('" . $title . "', '" . $target_file . "')";
  
          if ($conn-&gt;query($sql) === TRUE) {
              //echo "New record created successfully";
          } else {
              //echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
          }
  
          header("Location: upload.php?message=" . $message . "demo_form_get");
              } else {
                  $message = "Sorry, there was an error uploading your file. &lt;br&gt;";
          header("Location: upload.php?message=" . $message . "");
              }
          }    
          }
  
      ?&gt;
  </code></pre>