title: Login form with header location doesn't work properly
body: <p>I'm a bit new to PHP, and I'm trying to do the following in a login form:
  - index.php: Login (link to reglogin.php)
  - reglogin.php: either registration or login. When logging in: check if email is in database. If so --> login and go to succes page. The redirect to the succes page doesn't work.</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php session_start(); $page=(isset($_GET['page']))?$_GET['page']:"index"; ?&gt;
  &lt;!DOCTYPE html&gt;
  ....
  &lt;body&gt;
      &lt;?php include 'includes/header.php'; ?&gt;
  
      &lt;div class="content"&gt;
          &lt;?php
          $frontpage="page/home.php";
          $page404="page/404.php";
          $folder="page/";
  
          if ($page=="index") {
              include_once($frontpage);
          }
          else {
              include_once((file_exists($folder.$page.".php"))?$folder.$page.".php":$page404);
          }
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>includes/header.php</strong></p>
  
  <pre><code>&lt;div class="header"&gt;
      &lt;?php
          if (isset($_SESSION['email'])) {
              ?&gt;
              &lt;ul&gt;&lt;li&gt;&lt;a href="index.php?page=logout"&gt;Log out&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
          &lt;?php
          }
          else { ?&gt;
              &lt;ul&gt;&lt;li&gt;&lt;a href="index.php?page=reglogin"&gt;Log in&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
          &lt;?php }
          ?&gt;    
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Reglogin.php</strong></p>
  
  <pre><code>&lt;?php if (!isset($_SESSION['email'])) {  ?&gt;
      &lt;form method="post" action="index.php?page=logincheck" class="loginform"&gt;
          &lt;fieldset&gt;
              &lt;input type="text" name="login_email" /&gt;
              &lt;input type="text" name="login_password" /&gt;
              &lt;input type="submit" name="login_submit" /&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  &lt;?php } else { echo "U are already logged in"; } ?&gt;
  </code></pre>
  
  <p><strong>Logincheck.php</strong></p>
  
  <pre><code>&lt;?php
      session_start();
      include 'includes/config.php';
  
      // if session['email'] doesn't exit    
      if (!isset($_SESSION['email'])) {
      if (isset($_POST['login_email']) &amp;&amp; isset($_POST['login_password'])) {
                  $login_email = $_POST['login_email'];
          $login_password= $_POST['login_password'];       
  
                      if (!empty($login_email) &amp;&amp; !empty($login_password)) {
                          $query = 'SELECT Email, Password FROM tblregpersons
                                      WHERE Email="' . $login_email .  '"
                                      AND Password="' . $login_password .  '"';
                          if ($query_run = mysql_query($query)) {
                              $query_num_rows = mysql_num_rows($query_run);
                              if ($query_num_rows == 0) {
                                  echo "invalid";
                              }
                              else {
                                  $_SESSION['email'] = $_POST['login_email'];
                                  header('location: index.php?page=succes');
                                  exit();
  ***// This redirect doesn't work. The page stays on logincheck.php.***
                              }                     
                          }
                          else {
                              echo "query failed";
                          }
                      }                
                      else {
                          echo "Please fill in an email/password";
                      }
              }
              else {
                  echo "no post";
              }
      else {
          "U are already logged in";
      }
  ?&gt;
  </code></pre>
  
  <p>I work with <code>$_SESSION['email']</code>, because I also have a registration form, and I link this 'email' session to the POSTs of the registration and login form.</p>
  
  <p>What am I doing wrong in this redirection?</p>