-1

The form is submitting and sending the email successfully, but the page not redirecting to google. What am I doing wrong?

<?php
    $to = "test@gmail.com";
    $email_title = "test from email";


    if ($_SERVER["REQUEST_METHOD"] == "POST") {

            $name = ($_POST["name"]);
            $email = ($_POST["email"]);
            $message = ($_POST["message"]);

            $info = " Name: $name  \r\n Email: $email";

            if(mail($to, $email_title, $message, $info)){


                header('Location: http://www.google.com/');

            }
            else {

                echo "there is an error";
            }
        }   
?>

1 Answers1

0

Without knowing more (for example, what the actual error looks like or what actually happens in the browser), I can only speculate. Headers can only be sent before any data is sent to the browser. My best guess is something somewhere is sending data down to the browser before the header() call, which therefore negates the header redirect.

Kevin Eaton
  • 100
  • 3
  • 13