title: require() loaded after html is output
body: <p>In my code on index.php I require another script that performs a database query dependent on data i submitted in index.php. After pressing the submit button on index.php, index.php reloads and i expect the data being sent from index.php to be available in the required script. This is not always the case, sometimes the result of the query being performed in the required script is not available in index.php after the submit. Am i confusing something in terms of load-order/form submit or is this problem specific to some error in my script?</p>
  
  <p>Index.php :</p>
  
  <pre><code>session_name("bpsessid");
  session_start();
  
  
  
  include($_SERVER["DOCUMENT_ROOT"] . "/include/databaseconnect.php");
  
  $oc = mysql_connect($dbhost,$dbuser,$dbpassword);
  mysql_select_db($dbname);       
  
      if(isset($auftragsnummer1)) {
      $auftragsnummer1 = strtoupper($auftragsnummer1); 
      }
  
      require("sql.php");
  </code></pre>
  
  <p>sql.php :</p>
  
  <pre><code>    $sqlstring_2 = "SELECT DISTINCT [Ship-to Name] FROM [xxx] WHERE [Related to Sales Order No_]='".mysql_real_escape_string($auftragsnummer1)."' OR [No_]='".mysql_real_escape_string($auftragsnummer1)."' AND [No_] LIKE 'TI%'";
      $result_2 = sqlsrv_query($conn, $sqlstring_2);
      while( $row = sqlsrv_fetch_array($result_2, SQLSRV_FETCH_ASSOC) ) {
        $firma = $row['Ship-to Name'];
        echo $firma;
      }
  
  
      $sqlstring_3 = "SELECT DISTINCT [Ship-to Address] FROM [xxx] WHERE [Related to Sales Order No_]='".mysql_real_escape_string($auftragsnummer1)."' OR [No_]='".mysql_real_escape_string($auftragsnummer1)."' AND [No_] LIKE 'TI%'";
      $result_3 = sqlsrv_query($conn, $sqlstring_3, array(), array("Scrollable"=&gt;"buffered"));
      while( $row = sqlsrv_fetch_array($result_3, SQLSRV_FETCH_ASSOC) ) {
        $strasse = $row['Ship-to Address'];
        echo $strasse;
      }
  
      $sqlstring_4 = "SELECT DISTINCT [Ship-to Post Code] FROM [xxx] WHERE [Related to Sales Order No_]='".mysql_real_escape_string($auftragsnummer1)."' OR [No_]='".mysql_real_escape_string($auftragsnummer1)."' AND [No_] LIKE 'TI%'";
      $result_4 = sqlsrv_query($conn, $sqlstring_4, array(), array("Scrollable"=&gt;"buffered"));
      while( $row = sqlsrv_fetch_array($result_4, SQLSRV_FETCH_ASSOC) ) {
        $plz = $row['Ship-to Post Code'];
        echo $plz;
      }
  </code></pre>