表单提交后无法重定向

I have a form on a HTML page that has form data, and would like to have the user redirected to a new URL page after they have pressed the submit button and it has emailed the information. The form is called with the following button.

<div class="btnp"><input type="submit"  value="Continue to Billing" ></div>

The form then sends the data to my PHP file via post. I do not need a success echo message, I would just like the URL to be redirected to the payment page. Below is the PHP file I have set up. I am trying to submit, send email with form date, and then redirect to a new html url.

<?php
//Retrieve form data. 
//POST
$URL = "http://www.google.com"; 
$fname  = $_POST['fname'];              
$zip = $_POST['zip'];       
$phone = $_POST['phone'];       
$email = $_POST['email'];       

    //recipient - change this to your name and email
    $to = 'sales@mysite.com';   
    //sender
    $from = $fname . ' <' . $email . '>';

    //subject and the html message
    $subject = 'New User: ' . $fname;   
    $message = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head></head>
    <body>
        <table>
            <tr><td>First Name</td><td>' . $fame . '</td></tr>      
            <tr><td>Zip</td><td>' . $zip . '</td></tr>      
            <tr><td>Telephone</td><td>' . $phone . '</td></tr>  
            <tr><td>Email</td><td>' . $email . '</td></tr>  
        </table>
    </body>
    </html>';

    //send the mail
    $result = sendmail($to, $subject, $message, $from);

    if ($_POST) 
        if ($result) header('Location: '.$URL);
        else echo 'Sorry, unexpected error. Please try again later';

    //Simple mail function with HTML header
    function sendmail($to, $subject, $message, $from) {
    $headers = "MIME-Version: 1.0" . "
";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
    $headers .= 'From: ' . $from . "
";  
    $result = mail($to,$subject,$message,$headers);
    }       
?>    

use the header('Location: $url); snippet that your tried but correct the function to this:

header('Location: '.$URL);

just make sure the varibale $URL is defined.

To use the "header" function:

header("location: result.php");

You can't output/print/echo anything to the screen, so try this:

if ($_POST) 
        if ($result) header("location: result-page.php");
        else echo 'Sorry, unexpected error. Please try again later';

Or you can use javascript to print the success msg and redirect:

if ($_POST) 
        if ($result) { 
            print "<script>alert('Ok, email sent');</script>";
            print "<script>window.open('result-page.php','_self');</script>";
        }else{
            print 'Sorry, unexpected error. Please try again later';
        }