0
我很難讓這與我的表單一起工作。我已經看過這篇文章Show a Thank You message after validating contact form,但我再次無法爲我的工作。隱藏聯繫表單並淡入致謝您的郵件
我的表單代碼是
<li id="contact">
<form enctype="multipart/form-data" method="post" action="contact2.php" name="contactform" id="contactform">
<p>Jason Bartimus | Hawaii Wedding Photographer</p>
<h3>What type of session are you interested in?</h3>
<ul>
<li class="msgname"><label>Full Name: </label><input type="text" name="name"></li>
<li><label>E-mail: </label><input type="text" name="email"></li>
<li class="msgname"><label>Contact Number: </label><input type="text" name="phone"></li>
<li><label>Event Date: </label><input type="text" name="date"></li>
<li><label>Event Type: </label><select name="event">
<option>- - - - - - -</option>
<option value="Engagement">Engagement</option>
<option value="Wedding">Wedding</option>
</select></li>
<li><label>Message: </label><textarea name="message" rows=4 cols=35></textarea></li>
<li><input class="send" type="submit" value="Send"></li>
</ul>
</form>
<div id="contactinfo">
<h3>Contact Information</h3>
<p></p>
<p class="phone">808-343-0845</p>
<p class="email"><a href="#">[email protected]</a></p>
</div>
</li>
我的PHP代碼如下:
<?php
$ToEmail = '[email protected]';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "phone: ".$_POST["phone"]."<br>";
$MESSAGE_BODY .= "date: ".$_POST["date"]."<br>";
$MESSAGE_BODY .= "event: ".$_POST["event"]."<br>";
$MESSAGE_BODY .= "message: ".nl2br($_POST["message"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
我不知道如何得到這個工作。任何幫助將是偉大的!
我不知道如何讓這個工作。任何幫助將是偉大的! 試圖利用這個jQuery莫名其妙
$(function() {
var options = {
messages: {
firstname: "Please enter your Name",
lastname: "Please enter your Last Name",
email: "Please enter a valid E-mail Address",
comments: "Please enter your Comments"
},
submitHandler: function(form) {
$(form).ajaxSubmit({
beforeSubmit: function(arr, $form, options) {
$('#myform').fadeOut('fast');
$('#loader').fadeIn('slow');
return true;
},
success: processRegister
});
}
};
//Validation
$('#contactus').validate(options);
$('#ty').hide();
});
function processRegister(responseText, status) {
$('#loader').fadeOut(function() {
$('#ty').fadeIn();
});
}
顯示的任何錯誤? – random
沒有錯誤。該表格實際上運作良好。這只是我不知道如何添加提交後淡入的感謝頁面。我試過使用jsfiddle並整合這個http://stackoverflow.com/questions/5018848/show-a-thank-you-message-after-validating-contact-form但是無法使它工作。它仍然會去一個單獨的謝謝頁 – jbartimus
你的jQuery的樣子是什麼? – random