PHP Email Form and Redirect without using Header

Hello,

I have a form that on submit loads my custom mailer.php file, which sends me an email of the form data, and then displays the text " Your information has been recieved and a representative will respond shortly. Thanks "

Everything works great, but I want the page to redirect after 5 or 10 seconds back to the homepage. I cant get the header function to work because I want the php to output the text.

Here the code:
[php]<?php
if(isset($_POST[‘submit’])) {

$to = "[email protected]";
$subject = “Customer Contact”;
$name_field = $_POST[‘name’];
$company_field = $_POST[‘company’];
$email_field = $_POST[‘email’];
$phone = $_POST[‘phone’];
$message = $_POST[‘message’];

$body = “From: $name_field\n Company: $company_field\n E-Mail: $email_field\n Phone: $phone\n Message:\n $message”;

echo “Your information has been recieved and a representative will respond shortly. Thanks”;
mail($to, $subject, $body);

} else {

echo “Sorry, Something went wrong. Please try the form again!”;

}
?>
[/php]

How can I get another page to load from this page, with a delay, and still being able to display the thank you echoed text? Any ideas?

Hi,
To redirect after 5 or 10 second you need to put JavaScript on your page. You can use
var t=setTimeout(“window.location = ‘http://www.yourdomain.com’”,3000);

Sponsor our Newsletter | Privacy Policy | Terms of Service