I am working with a mail. What I exactly want is the page should be redirected to the universal resource locator after 5 seconds. The header line is working fine in all other files but not in this file. I tried my best to find what is wrong. The before and after line is also working fine but the page is not redirecting. And even I have checked the code many time and there is no error.
Can you please tell me the reason why is it happening?
Code
<?php
if (isset($_POST['fullname']) && isset($_POST['email']) && isset($_POST['message']) && isset($_POST['submit'])) {
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "ziajappa1@gmail.com";
$subject = "Customer";
$txt = "Hi, Grand4Love ".$fullname." have contacted you. Do hurry to contact him back! The user's email address is: ".$email."";
$headers = "From: client@perfecttips.com
";
//."CC: somebodyelse@example.com";
if(mail($to,$subject,$txt,$headers)){
echo "<h2>Thank you for contacting us, we will respond to your message withing 24 hrs<h2>";
}
header('refresh:5; url=http://perfecttips.co/');
// The above line is working in the other files but not here.
// Please suggest me why the above line is not working?
echo "hi";
}
?>
Is there anything that is included in this file that is written to the response before the header is parsed?
Headers need to be the first thing that page parses, or else it will be ignored.
Look for echoes or something in previously imported files.
Edit:Yup. You are echoing. Comment out all echoes and you'll see it should work.