How do I redirect to an HTML page after submitting a PHP email form?

13,410

Add this to the end of the script:

header("Location: URL");

where URL is the URL of the page you want to redirect to.

Share:
13,410
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    Here is my code:

    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $formcontent = "From: $name \n Email: $email \n Subject: $subject \n Message: $message";
    $recipient = "[email protected]";
    $subject = "Contact Form";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    ?>
    

    I just need to know how to redirect to an HTML page after clicking submit and to make sure that the script with send the email. Any help will be greatly appreciated!