Q: Checking $_POST data I'm doing some spam checking on a form. The code below works as it should on my localhost (redirect to google.com if true), however, it doesn't when it's on the production server (Executes the rest of the script and DOES NOT redirect to Google.com).
    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");
    } else {
       //Process form here

I've done a var_dump on $_POST and it is 1969-12-31
What am I doing wrong?

A: You should exit; after sending a location header in order to prevent the rest of the script from executing.
e.g.
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 can be undefined.
