I have created a contact form in PHP. The form works fine and sends the message but when I try to redirect users to my thank you page I receive a headers already sent message.
My form starts:
<form name="myform" id="myform" class="form-foot" action="/receiving.php" method="post">
And the PHP code for receiving.php is:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
if(isset($_POST['submit']))
{
$from_add = "mysite@mysite.com";
$to_add = "mysite@mysite.com";
$subject = "Contact Form";
$message = "
Name:$name \n
Email: $email \n
Message: $message \n
$headers = "From: $from_add \r\n";
$headers .= "Reply-To: $from_add \r\n";
$headers .= "Return-Path: $from_add\r\n";
$headers .= "X-Mailer: PHP \r\n";
if(mail($to_add,$subject,$message,$headers))
{
Header("Location: /thanks");
}
}
?>
How can I redirect users to www.mysite.com/thanks after successful submission?