0

我得到了这个mail.php。即使在成功发送电子邮件后,我的联系表单与用户提交的数据保持不变,aajaxalert 说谢谢您发送但如果愚蠢的用户错过了该消息,则该消息仅保留几秒钟,然后他可能会尝试再次单击“发送”消息。如何重置整个表格?

<?php
    header('Content-Type: text/html; charset=utf-8');
    function sendFeedback($feedback_email, $feedback_msg,
            $feedback_name  , $feedback_subject)
     {
        /* EDIT THIS */
        $admin_email = "mail@website.com";
        if ($feedback_subject == "Subject" || empty($feedback_subject) ) {
            $subj = "Email from website.com.au";
        } else {
            $subj = $feedback_subject;
        }
        /* //EDIT THIS */

        $message = "
        <html>
        <head>
          <title>Email from your site</title>
        </head>
        <body>
            <p><a href='mailto:".$feedback_email."'>".$feedback_name."</a>
                       send this message:</p>
            <p>".$feedback_msg."</p>
            <p>".$subject."</p>
        </body>
        </html>
        ";
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";

        if (($feedback_name!=="Name" &&
             $feedback_email!=="Email" &&
             !empty($feedback_email
           ) && (
                  !empty($feedback_msg) && 
                  !empty($feedback_name))
              {
            if($feedback_email == "mail_error")
            {
              echo "<span class='ajaxok'>$feedback_name , You entered an
                            Invalid email address.</span>";
            } else {            
                mail($admin_email, $subj, $message, $headers);
                echo "<span class='ajaxok'>Thank You! $feedback_name,
                                  Your message has been sent.</span>";  
                }
        } else {
            echo "<span class='ajaxalert'>Hi $feedback_name you forgot to type
                    the  message. </span>";     
        }   
    }

    sendFeedback($_POST['email'], 
      $_POST['message'], $_POST['name'], $_POST['subject']);
    ?>
4

2 回答 2

0

从 ajax 页面获得响应后,您当时正在显示消息,您可以使用 javascript 重置或清空输入字段。

于 2013-06-07T13:47:33.207 回答
0

您可以为此使用 js.reset()函数。它将表单值重置为其默认值。

var form = getElementById('form_id');
form.reset();
于 2013-06-07T13:49:51.527 回答