LeBlaireau LeBlaireau - 3 months ago 10
PHP Question

php redirect issue after email sent

I am getting the old header problem just cant get it to redirect how do I fix it?

Warning: Cannot modify header information - headers already sent

<?php if (isset($_POST['email']))
{
$content = '<html><body>';
$content .= 'Email Address: '.$_POST['email'].'<br />';
$content .= 'Enquiry Type: '.$_POST['enquiry'].'<br />';
$content .= 'Message: '.$_POST['message'].'<br />';
$content .= 'Telephone Number: '.$_POST['telephone'].'<br />';
$content .= 'Preferred Contact Method:" '.$_POST['contact-method'] ;
$content .= '</body></html>';
$to = 'myemail*email.com';

$subject = 'Website Contact Form ';

$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (mail($to, $subject, $content, $headers)) {
header('Location:form-submitted.php');
}

}
?>
<!DOCTYPE html>
<html>

Answer

It means that header is already been sent. Please try this

echo "<meta http-equiv='refresh' content=\"0; url=form-submitted.php\">";