0

メールの送信に php mail() を使用しています。この機能により、メールは正常に送信されています。しかし、メールページを送信した後、正しく読み込まれません。実際には、メールを送信した後に同じページに着陸したいと考えています。以下は私が書いたコードです

 if (isset($_POST['submit'])) { // Check if form was submitted

    if (empty($_POST['name']) ||
        empty($_POST['email']) ||
        empty($_POST['phone']) ||
        empty($_POST['subject']) ||
        empty($_POST['message']) ||
        !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        echo "No arguments Provided!";
        return false;
    }

    $name = strip_tags(htmlspecialchars($_POST['name']));
    $email_address = strip_tags(htmlspecialchars($_POST['email']));
    $phone = strip_tags(htmlspecialchars($_POST['phone']));
    $subject = strip_tags(htmlspecialchars($_POST['subject']));
    $message = strip_tags(htmlspecialchars($_POST['message']));

// Create the email and send the message
    $to = 'myemail@gmail.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
    $email_subject = "Subjet : $subject";
    $email_body = "You have received a new message from your website contact form.\n\n" . "Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
    $headers = "From: myemail@gmail.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@gmail.com.
    $headers .= "Reply-To: $email_address";
    mail($to, $email_subject, $email_body, $headers);
    header("Refresh:0");
    return true;
   
    // exit();

}

お問い合わせページです ここに画像の説明を入力

電子メールを送信した後、このページは完全にはロードされず、ヘッダーのみがロードされます ここに画像の説明を入力

4

1 に答える 1