title: Redirect doesn't work properly
body: <p>My signin procedure looks like that:</p>
  
  <ul>
  <li>User fills email and pass fields</li>
  <li>Ajax sends these fields to <code>reg_system.php</code>. Here is source code of
  file</li>
  </ul>
  
  <p>. </p>
  
  <pre><code>if (isset($_POST['formID']) &amp;&amp; !empty($_POST['formID'])) {
      $registration = new registration($db);
      $forms = array('signup_form', 'signin_form', 'tcr_form');
      if (in_array($_POST['formID'], $forms)) {
          $redirect = "";
          switch ($_POST['formID']) {
              case 'signin_form':
                  if ($registration-&gt;signin())
                      $redirect ='me';
                  break;
              case 'tcr_form':
              case 'signup_form':
                  $registration-&gt;signup();
                  break;
          }
      }
      if (!empty($redirect))
           header("Location:".wsurl."?page=".$redirect); 
  }
  </code></pre>
  
  <p><em>Note</em>: wsurl declared before, and is right value.</p>
  
  <ul>
  <li>If <code>$registration-&gt;signin()</code> returns true it must redirect to
     <code>domain.com/?page=me</code></li>
  </ul>
  
  <p>During debug process, I see that all goes well and $registration->signin() function returns true.But right after post process Firebug XHR shows this screen</p>
  
  <p><img src="https://i.stack.imgur.com/k11Fl.png" alt="enter image description here"></p>
  
  <p>Then after redirection
  <img src="https://i.stack.imgur.com/ofM03.png" alt="enter image description here"></p>
  
  <p>Page stays as it is: on the same login page. Script doesn't redirect to anywhere..</p>
  
  <p>I don't know what can cause this, because checked whole debug process nearly 10x time. PHP doesn't output anything before header(). </p>