1

これは、フォームに使用している PHP コードです。$headers を追加して、フォームが送信されたときに感謝のページにリダイレクトしたい。お礼のページが表示されるのですが、メールが届きません。

<?php

$action = $_SERVER['PHP_SELF'];

    $fname = $_POST['fname'];
    $phone = $_POST['phone'];
    $e_mail = $_POST['e_mail'];
    $service = $_POST['service'];
    $maker = $_POST['maker'];
    $model = $_POST['model'];
    $year = $_POST['year'];
    $message = $_POST['message'];

$to = 'reckless.sam@gmail.com';
$headers = 'From: Micheal Key <reply@locallockman.com>';
$subject = 'Customer Service Request';
$body = 'Customer name: ' . $fname .  "\n" .  
'Contact-No: ' . $phone .  "\n" . 
'E-mail: ' . $e_mail .  "\n" .
'Service-Type: ' . $service .  "\n" .  
'Car-Make: '. $maker .  "\n" . 
'Car-Model: ' . $model .  "\n" . 
'Model-Year: ' . $year .  "\n" . 
'Service Required: ' . $message .  "\n" ;
$thankyou = "thankyou.html"; // thank you page
if(isset($_POST['fname']) && isset($_POST['phone']) && isset($_POST['e_mail']) && isset($_POST['service']) && isset($_POST['message']))

$maker = $model = $year = 'Not Set'; // Or just use a empty string: '';
if(isset($_POST['maker'])){
    $maker = $_POST['maker'];
}
if(isset($_POST['model'])){
    $model = $_POST['model'];
}
if(isset($_POST['year'])){
    $year = $_POST['year'];
}{
    $fname = $_POST['fname'];
    $phone = $_POST['phone'];
    $e_mail = $_POST['e_mail'];
    $type = $_POST['service'];
    $maker = $_POST['maker'];

    $model = $_POST['model'];

    $year = $_POST['year'];
    $message = $_POST['message'];

    if(empty($phone)){
        echo 'Fields With * Sign Are Mandatory';
    }
    else{
        if(mail($to,$headers,$subject,$body,$headers)){
     header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>
<?
        }
        else{
            echo 'There was an error sending email/s.';
        }
    }

}


?>

回答お待ちしております。何か知りたいことがあれば教えてください。前もって感謝します。

4

2 に答える 2

2

これを使用するだけで、必要はありません<script>

if(mail($to,$subject,$body,$headers)){
    header("Location: $thankyou");
}
于 2013-04-23T10:54:57.860 に答える