title: PHP redirect to another page and pass value?
body: <p>I have a problem where I need to redirect to another page and pass a value, which is easy and I know how to do, except that theres the old header problem: <strong>Cannot modify header information - headers already sent by ... line 17</strong></p>
  
  <pre><code>&lt;?php include('m_a2_functions.php'); ?&gt;
  &lt;?php global_header(LOGIN); ?&gt;
  &lt;?php login(); ?&gt;
  &lt;?php 
  if(isset($_POST['submit']))
  {
      connect();
      $username = $_POST['username'];
      $password = $_POST['password'];
  
      $query = "SELECT password from users where username = '$username'";
      $result = mysql_query($query) or die ("There was an error executing the query $query:&lt;br/&gt;".mysql_error());
      $row = mysql_fetch_array($result);
      $encrypted_pass = $row[0];
  
      if (crypt($password, $encrypted_pass) == $encrypted_pass) {
          $flag = "y";
          header('Location: m_a2_view.php?flag=y');
      }
  
  }
  ?&gt;
  &lt;?php validation(); ?&gt;
  &lt;?php page_footer(); ?&gt;
  </code></pre>
  
  <p>This is all fine, except that there is a problem with the header part. It won't redirect.</p>
  
  <p><strong>GLOBAL HEADER FUNCTION IN FUNCTIONS.PHP</strong>  </p>
  
  <pre><code>&lt;?php function global_header($page_title){ ?&gt;
  &lt;?php echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'; ?&gt; &lt;- LINE 17
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"&gt;
      &lt;head&gt;
          &lt;title&gt;&lt;?php echo "MARK - " . $page_title; ?&gt;&lt;/title&gt;
          &lt;link rel="stylesheet" href="style.css" /&gt;
      &lt;/head&gt; 
      &lt;body&gt;
      &lt;div id="container"&gt;
      &lt;div id="logo"&gt;&lt;/div&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p><strong>LINE 17</strong></p>
  
  <pre><code>&lt;?php echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'; ?&gt;
  </code></pre>
  
  <p>I know that's what is causing it. It loads global_header at the start of my page and then can't redirect to another page. Soon as I hit submit, my page should redirect, but it cannot!</p>
  
  <p>Even if I start removing things, it won't work. It will EVENTUALLY work after getting rid of global_header() completely, something which I can't do.</p>