fronthem
fronthem

Reputation: 4139

PHP redirect doesn't work on IE?

I try to put script to send an email and redirect to main page. yes, it's work! but...

On IE, it doesn't work.

code example:

<?php
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    //$email_to1 = "[email protected]";
    $email_to2 = "[email protected]";
    $email_subject = "Email from www.abc.com";         
    ................
    ................                  
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    //@mail($email_to1, $email_subject, $email_message, $headers);
    @mail($email_to2, $email_subject, $email_message, $headers);
    header("Refresh: 3; http://www.abc.com/Contact.html");
?>

<!-- include your own success html here -->

    Thank you for contacting us. We will be in touch with you very soon.<br>
    <a href="http://www.abc.com/Contact.html">back to website</a>
<?php
}
?>

How could i solve it?

Upvotes: 0

Views: 1397

Answers (3)

Daan Timmer
Daan Timmer

Reputation: 15047

Change

header("Refresh: 3; http://www.abc.com/Contact.html");

into

header("Refresh: 3; URL=http://www.abc.com/Contact.html");

I think that should do the trick

Also take note of this answer: 'Refresh' HTTP header and this comment: 'Refresh' HTTP header

Upvotes: 0

Praveen kalal
Praveen kalal

Reputation: 2129

Please use below code

  header('Location:http://www.abc.com/Contact.html')
    exit;

Upvotes: 2

Denis O.
Denis O.

Reputation: 1850

Use this code instead

die(header('Location:http://www.abc.com/Contact.html'));

You can omit die(), but is useful here, because using it allows to prevent script running after sending redirect header.

Upvotes: 0

Related Questions