I am working with PHP and I got this message
cannot modify header information - headers already sent by (output started at
after executing a code which looks like this:
<?php
if (condition) {
if (condition) {
//Statement
}
$to = $_POST['email'];
$subject = "Registration Confirmation";
$message = '
<html>
<head>
<title>'.$subject.'</title>
</head>
</html>
';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <contact@ghanalifestore.com>' . "\r\n";
mail($to,$subject,$message,$headers);
header('Location: reset.php?username='.$username);
exit();
}else {
//statement
}
Based on this answer from Stackoverflow, I think the error is coming from the HTML code in the variable $message
. I don't really know how I can modify the content of that variable to avoid the error.
Kindly help me solve this problem.