Hi,

I've build a contact form and it works, but I can't get the thankyou message to appear. I keep getting the following error message which I don't understand as I can see anything wrong with line 46. Any suggestions...I'm new!

Warning: Cannot modify header information - headers already sent by (output started at /home/content/24/10758824/html/contact.php:2) in /home/content/24/10758824/html/contact.php on line 46


PHP Code:

<?php 

if ($_SERVER["REQUEST_METHOD"] =="POST") {
    
$name $_POST ["name"];
    
$email $_POST ["email"];
    
$message $_POST ["message"];
    
    foreach( 
$_POST as $value ){
        if( 
stripos($value'Content-Type:') !== FALSE){
            echo 
"There was a problem with the information you entered.";
            exit;
        }
    }
    
    if (
$_POST["twitter"] != "") {
        echo 
"Your form has an error";
        exit;
    }
    
    require_once(
"inc/phpmailer/class.phpmailer.php");
    
$mail = new PHPMailer();
    
    
    
$email_body "";
    
$email_body $email_body "Name: " $name ."<br>";
    
$email_body $email_body "Email: " $email "<br>";
    
$email_body $email_body "Message: " $message;
    
    
    
$mail->SetFrom($email$name);
        
    
$address "my@email.com";
    
$mail->AddAddress($address"myaddress");
    
    
$mail->Subject    "contact |" $name;
        
    
$mail->MsgHTML($email_body);
    

if(!
$mail->Send()) {
  echo 
"Mailer Error: " $mail->ErrorInfo;
  exit;

    
[
B] (LINE 46) [/B]  header('Location:contact-thanks.php?status=thanks');
    exit;
    }
    
?>
Thanks,
Matt