邮件发送成功后,如何重置我的联系人表单?



维护用户在邮件发送成功后提交的联系人表单。

按下提交按钮后,我希望页面会被重置(重新加载)。

我已经找了所有类似的问题,我不知道该怎么办,因为它和我不一样。

第二,当您按下提交按钮时,邮件到达my@domail.com,但当您打开邮箱时,到达内容页。宽度,太窄。

Div id='success_page'
<fieldset>
echo "<div id='success_page'>

我不知道div id='success_page'的设置值在哪里。

Id=success_page在css中找不到

<form method="post" action="php/contact.php" name="contactform" id="contactform">
<input name="name" type="text" id="name"  onClick="this.select()" value="Name" >
<input name="email" type="text" id="email" onClick="this.select()" value="E-mail" >            
<input type="text"  name="phone" id="phone" onClick="this.select()" value="Phone" > 
<textarea name="comments"  id="comments" onClick="this.select()" >Write something here!</textarea>
<button type="submit"  id="submit"  data-top-bottom="transform: translateY(-50px);" data-bottom-top="transform: translateY(50px);"><span>Send Message </span></button>                                                                                                      
</form>
$address = "my@mydomain.com";
$e_subject = 'Hello - by' . $name ;
$e_reply = "name: $name" . "rn". "e-email: $email". "rn". "phone: $phone" . "rn". "rn" ;
$e_content = ""$comments"" . PHP_EOL . PHP_EOL;
$msg = wordwrap( $e_body . $e_reply . $e_content, 70 );
$headers = array("From: $_POST[contactform_sender_email]"); // No!
$headers = array("From: $email",
"Reply-To: $email",
"X-Mailer: PHP/" . PHP_VERSION
);
$headers = implode("rn", $headers);
mail($to, $subject, $message, $headers);
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
if(mail($address, $e_subject, $msg, $headers)) {
echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h3>Email Sent Successfully.</h3>";
echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
echo "</div>";
echo "</fieldset>";
} else {
echo 'ERROR!';
// contact form .js------------------
$("#contactform").submit(function() {
var a = $(this).attr("action");
$("#message").slideUp(750, function() {
$("#message").hide();
$("#submit").attr("disabled", "disabled");
$.post(a, {
name: $("#name").val(),
email: $("#email").val(),
phone: $("#phone").val(),
comments: $("#comments").val()
}, function(a) {
document.getElementById("message").innerHTML = a;
$("#message").slideDown("slow");
$("#submit").removeAttr("disabled");
if (null != a.match("success")) $("#contactform").slideDown("slow");
});
});
return false;
});
$("#contactform input, #contactform textarea").keyup(function() {
$("#message").slideUp(1500);
});

将值设置为空字符串。

$("#contactform").submit(function() {
var a = $(this).prop("action");
$("#message").slideUp(750, function() {
$("#message").hide();
$("#submit").prop("disabled", "disabled");
$.post(a, {
name: $("#name").val(),
email: $("#email").val(),
phone: $("#phone").val(),
comments: $("#comments").val()
}, function(a) {
document.getElementById("message").innerHTML = a;
$("#message").slideDown("slow");
$("#submit").removeAttr("disabled");
if (null != a.match("success")){
$("#contactform").slideDown("slow");
$("#name").val('');
$("#email").val('');
$("#phone").val('');
$("#comments").val('');
};
});
});
return false;
});

$("#contactform").submit(function() {
var a = $(this).prop("action");
$("#message").slideUp(750, function() {
$("#message").hide();
$("#submit").prop("disabled", "disabled");
$.post(a, {
name: $("#name").val(),
email: $("#email").val(),
phone: $("#phone").val(),
comments: $("#comments").val()
}, function(a) {
document.getElementById("message").innerHTML = a;
$("#message").slideDown("slow");
$("#submit").removeAttr("disabled");
if (null != a.match("success")){
$("#contactform").slideDown("slow");
$('#contactform')[0].reset();  // reset all form fields here.
};
});
});
return false;
})

相关内容

  • 没有找到相关文章

最新更新