header() is not executed (possible due to mail function)
<p>On my website www.LolStreamGallery.net (which btw is still a little under construction) I use a contact form, which causes me a lot of trouble.
I already spent some time on actually get the mail() PHP function working on 64bit Debian with exim4, but I finally did it, and mails are sent. (Hurray)</p>

<p>But now i am experiencing another problem, which i cant figure out how to solve. First of all the code. (its not the whole code of course, but i guess this is the only essential part)</p>

<pre><code>&lt;?php 
$your_email ='blahblah@gmail.com';
session_start();
$errors = '';
$name = '';
$visitor_email = '';
$user_message = '';

    if(isset($_POST['submit']))
    {



    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $user_message = $_POST['message'];
    ///------------Do Validations-------------
    if(empty($name)||empty($visitor_email))
    {
        $errors .= "\n Name and Email are required fields. ";   
    }
    if(IsInjected($visitor_email))
    {
        $errors .= "\n Bad email value!";
    }
    if(empty($_SESSION['6_letters_code'] ) ||
      strcmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
    {
    //Note: the captcha code is compared case insensitively.
    //if you want case sensitive match, update the check above to
    // strcmp()
        $errors .= "\n The captcha code does not match!";
    }

    if(empty($errors))
    {
        //send the email
        $to = $your_email;
        $subject="New form submission";
        $from = $your_email;

        $body = "A user  $name submitted the contact form:\n".
        "Name: $name\n".
        "Email: $visitor_email \n".
        "Message: \n ".
        "$user_message\n";  

        $headers = "From: $from \r\n";
        $headers .= "Reply-To: $visitor_email \r\n";

        if(mail($to, $subject, $body, $headers)) {
            header('Location: http://www.lolstreamgallery.net/thank-you.html');
        }
        else {
            $errors .= "\n E-Mail coulnd be sent!";
        }
     }
}
</code></pre>

<p>Basicly what my problem is, that the header redirection is not working, but as I said before the mail does work, so the header should be executed. I also tested the file on my local server, and there the redirection works, so Im guessing its maybe the mail function which is executed on the server, and on localhost is not, which is causing the header to not work? 
I hoped maybe some of you will know where the problem is, and know how I could fix it.</p>

<p>If you wanna test the contact form, you can do it here <a href="http://lolstreamgallery.net/RequestStream.php" rel="nofollow">http://lolstreamgallery.net/RequestStream.php</a> but dont spam me too much plz :)</p>

<p>Thx for all the answers in advance and sorry for english not being my main language.</p>

<p>EDIT:</p>

<p>Here is the whole file code:
<a href="http://codeviewer.org/view/code:2ecd" rel="nofollow">http://codeviewer.org/view/code:2ecd</a></p>

<p>EDIT2:</p>

<p>Im now using the function of Ian Brindley which made he redirect working, but not the header function. It seems there is some output before the header. So I would still be happy if someone could find the reason why header wont work.</p>
