title: Using multiple PHP files while avoiding redirect loop and resubmission
body: <p>So I am pretty new to PHP, I have done and learnt lots of console based experience so I'm not a full beginner to programming. But I decided to learn how to database because its always fascinated me, and I've learnt the basic HTML and CSS and JS, and now basic PHP and SQL, but putting into action is getting weird on me.</p>
  
  <p>I've figured out how to manipulate and make databases through PHP code and stuff like that, but they were all simple things and in one file, I am going for a bigger project and I need to put all the PHP's in separate files, this is the problem.</p>
  
  <p>say my 'index.php' file is so:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;?php include 'other.php' ?&gt;    //Problem 1
      &lt;/head&gt;
      &lt;body&gt;
          &lt;FORM method="POST" action="other.php"&gt;
              &lt;INPUT type="text" name="textTest" value="&lt;?php print $input; ?&gt;"&gt;
              &lt;INPUT type="submit" name="subTest" value="TEST" &gt;
          &lt;/FORM&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and my 'other.php' is :</p>
  
  <pre><code>&lt;?php
  
  $input = "";
  
  if (isset ($_POST['subTest']))
  {
      $input = $_POST['textTest'];
  
      //header("Location : index.php");
  }
  
  header("Location: index.php");   //Problem 2
  
  ?&gt;
  </code></pre>
  
  <p>so my problems:</p>
  
  <ul>
  <li><p>Problem 1, if I don't include the 'other.php' file, there is an error when I try print the: value = "print $input"</p></li>
  <li><p>Problem 2, if I don't redirect with 'header', it obviously doesn't redirect and go back to the 'index.php' which I want to happen. BUT with it there, it causes a TOO_MANY_REDIRECT error. I found this is a problem caused by the include which can't be removed for Problem 1 reasons.</p></li>
  <li><p>Problem 3, I found out I could move the 'header' function to where it is commented out, but then the value="..." doesn't stay on submit.</p></li>
  <li><p>Problem 4, if I completely get rid of the 'header' redirect, and change the form's action to 'index.php', then I get the 'Confirm Form Resubmission' thing I want to avoid.</p></li>
  </ul>
  
  <p>So I hope that is a mouthful someone understands and can help with, and thankyou in advanced.</p>