title: PHP redirect to page with variable in URL
body: <p>I have a page, <code>q.php</code>, that is a user submitted post defined by its id, (for example, <code>q.php?id=1</code> would be a certain post that uses the <code>$id</code> variable to pull all the rest of the information from the database).</p>
  
  <p>I am trying to code a comment submission on the same page, and account for the fact that a user might not enter anything into the field. If this happens, I want the page (e.g. <code>q.php?id=1</code>) to load again with an error message.</p>
  
  <p>I can do the error message with an empty variable that is then given a value by the php file that the form activates. However, I am having a problem navigating back to the specific post. I tried to use <code>include('q.php?id=$id)</code> where $id is set to a number, but I understand that this is not its purpose and it does not accept variables</p>
  
  <p>What should I be using instead?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>answer.php (file that the form activates):</p>
  
  <pre><code>require 'q.php';
  $_GET['id'] = $id;
  $_SESSION['error'] = "Please fill in all of the fields.";
  </code></pre>
  
  <p>q.php:</p>
  
  <pre><code>if ($_SESSION['error'] !== 0) {
      echo "&lt;p style='color: #AA1111;'&gt;".$_SESSION['error']."&lt;/a&gt;";
      unset($_SESSION['error']); // this isn't happening...
  }
  </code></pre>