Using php script to allow people to add their email to a mailing list. When it successfully writes the email to the .txt doc it displays a success message on a white page. I want it to redirect to a page I've designed to look like the rest of the site. I've read elsewhere that I need to use the header function, but I can't figure out where to put it since the preceding portion of my code contains outputs.
I think this is the relevant code:
// Write to file if email doesn't already exist
if ($emailexists != "yes") {
// Write to the list and give success message
fwrite($fh, "$_POST[email]
");
$msg = "Your e-mail address $EmailFix was successfully added to the list!";
}
// Close the list
fclose($fh);
}
Then this:
// Show success message if there was one and end script, and no errors were encountered
} elseif (isset($msg)) {
echo "<b>" . $msg . "</b>
";
echo "</body>
";
echo "</html>
";
exit;
}