This question already has an answer here:
I am trying to redirect the contact form back to the index page once it has successfully been sent. I have so far built the infrastructure to check the message has successfully sent and echo "Thank You!" once it has been successful. Am I able to replace the echo to redirect instead of show an empty page with just text.
<?php
$name = $_POST['name'];
$company = $_POST['company'];
$mailFrom = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$txt="Name: $name
Company: $company
Email: $mailFrom
Telephone: $phone
Message: $message";
$mailTo = "info@company.com";
$subject = "RE: You Have A New Message!";
$headers = "From: $mailFrom
";
mail($mailTo, $subject, $txt, $headers) or die("Error!");
echo "Thank You!";
?>
</div>