You should exit;after sending the location header to prevent the rest of the script from executing.
eg.
if('POST' == $_SERVER['REQUEST_METHOD']) {
if ($_POST["bait"]!='' || $_POST["date"] == "12/31/69" || trim($_POST["date"] == "1969-12-31")) {
header("location: http://www.google.com");
exit;
} else {
// process form here
}
}
The redirect is sent, but you also continue to output the rest of the request, in which case the behavior may be undefined.
source
share