title: PHP Header Location not working on live server
body: <p>I have a simple registration form set up, on sending the details to my function to put the data in the database I want the page to redirect to a success page...</p>
  
  <p>This works brilliantly on my local server but when I uploaded it to my live server its just not redirecting</p>
  
  <p>The redirect that is not working is on line 65 :) it just redirects to register.php?success</p>
  
  <p>Any help would be gratefully received. I've seen a few people have had the same problem but their solution would not work for me :(</p>
  
  <p>ALL other header locations work. just this one won't :@</p>
  
  <pre><code>    &lt;?php
      include 'core/init.php';
      //check if logged in
      logged_in_redirect();
      include 'includes/overall/header.php'; 
  
  if (empty($_POST) === FALSE) {
      $required_fields = array('username', 'password', 'password_again', 'first_name', 'last_name', 'email');
      foreach ($_POST as $key =&gt; $value) {
          if (empty($value) &amp;&amp; in_array($key, $required_fields) === true) {
              $errors[] = 'You appear to have missed something out, all fields are required.';
              break 1;
  
          }
      }
  
      if (empty($errors) === true) {
          if (user_exists($_POST['username']) === true ) {
              $errors[] = 'Sorry, the username \'' . $_POST['username'] . '\' is already taken.';
          }
          if (strlen($_POST['username']) &lt; 6) {
              $errors[] = 'Sorry, your username must be at least 6 characters.';
          }
          if (strlen($_POST['username']) &gt; 25) {
              $errors[] = 'Sorry, your username must be under 25 characters.';
          }
          if (preg_match("/\\s/", $_POST['username']) == true) {
              $errors[] = 'Your username must not contain any spaces.';
          }
          if (strlen($_POST['password']) &lt; 6) {
              $errors[] = 'Sorry, your password must be at least 6 characters.';
          }
          if ($_POST['password'] !== $_POST['password_again']) {
              $errors[] = 'Sorry, your passwords do not match.';
          }
          if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false ) {
              $errors[] = 'Sorry, you did not provide a valid email address.';
          }
          if (email_exists($_POST['email']) === true ) {
              $errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already registered to an account.';
          }
      }
  }
  
  ?&gt;
  &lt;h1&gt;Register&lt;/h1&gt;
  
  &lt;?php 
  if (isset($_GET['success']) &amp;&amp; empty($_GET['success'])) {
      echo "You have been registered successfully.";
  } else {
      if (empty($_POST) === false &amp;&amp; empty($errors) === true) {
          // register user
          $register_data = array(
              'username'      =&gt; $_POST['username'],
              'password'      =&gt; $_POST['password'],
              'first_name'    =&gt; $_POST['first_name'],
              'last_name'     =&gt; $_POST['last_name'],
              'email'         =&gt; $_POST['email'],
              'email_code'    =&gt; md5($_POST['username'] + microtime())
          );
  
          register_user($register_data);
          //header location not working *********************
          header('Location: register.php?success');
          exit();
  
      } else if (empty($errors) === false) {
          //error output
          echo output_errors($errors);
      }
  
  ?&gt;
      &lt;form action="" method="post"&gt;
          Register your account here, all fields are required.
          &lt;ul&gt;
              &lt;li&gt;
                  Username: &lt;/br&gt;
                  &lt;input type="text" name="username"/&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  Password: &lt;/br&gt;
                  &lt;input type="password" name="password"/&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  Repeat Password: &lt;/br&gt;
                  &lt;input type="password" name="password_again"/&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  First Name: &lt;/br&gt;
                  &lt;input type="text" name="first_name"/&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  Last Name: &lt;/br&gt;
                  &lt;input type="text" name="last_name"/&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  Email: &lt;/br&gt;
                  &lt;input type="text" name="email"/&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;input type="submit" value="Register"/&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/form&gt;
  
  &lt;?php 
  }
  include 'includes/overall/footer.php'; 
  
  
  ?&gt;
  </code></pre>