我的表单有问题。 Submition似乎有效(褪色动画有效)但我没有收到电子邮件。以下代码中是否有任何错误?
<div id="section-4">
<div class="twelve columns">
<h3>Would you like to cooperate?
Get in touch</h3>
<p></p>
<div id="success">
<span class="green textcenter">
<p>Your message was sent successfully! I will be in touch as soon as I can.</br><a href="http://www.ewelinawoloszyn.com">Refresh the page here.</a></p>
</span>
</div>
<div id="error">
<span>
<p>Something went wrong, try refreshing and submitting the form again.</p>
</span>
</div>
<form id="contact" name="contact" method="post" novalidate="novalidate">
<fieldset>
<label for="email" id="email">Email<span class="required">*</span>
</label>
<input type="text" name="email" id="email" size="30" value="" required="">
<label for="Message" id="message">Message<span class="required">*</span>
</label>
<textarea name="message" id="message" required=""></textarea>
<label for="Answer" id="answer">Name the small house pet that says “<i>meow</i>“<span class="required">*</span>
</label>
<input type="text" name="answer" value="" required=""></br>
<input id="submit" type="submit" name="submit" value="Send">
</fieldset>
</form></div>
</div>
<hr/>
<footer>
All rights reserved.
</footer></div><script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.32/jquery.form.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript">
jQuery.validator.addMethod('answercheck', function (value, element) {
return this.optional(element) || /^\bcat\b$/.test(value) || /^\bkitten\b$/.test(value) || /^\bkot\b$/.test(value) || /^\bkotek\b$/.test(value);
}, "Type the correct answer ;)");
// validate contact form
$(function() {
$('#contact').validate({
rules: {
email: {
required: true,
email: true
},
message: {
required: true
},
answer: {
required: true,
answercheck: true
}
},
messages: {
email: {
required: "No email, no message"
},
message: {
required: "Please write something to send this form.",
minlength: "This message is too short."
},
answer: {
required: "Sorry, wrong answer!"
}
},
submitHandler: function(form) {
$(form).ajaxSubmit({
type:"POST",
data: $(form).serialize(),
url:"process.php",
success: function() {
$('#contact :input').attr('disabled', 'disabled');
$('#contact').fadeTo( "slow", 0.15, function() {
$(this).find(':input').attr('disabled', 'disabled');
$(this).find('label').css('cursor','default');
$('#success').fadeIn();
});
},
error: function() {
$('#contact').fadeTo( "slow", 0.15, function() {
$('#error').fadeIn();
});
}
});
}
});
});
</script>
这是Php代码:
<?php
$to = "youremail@gmail.com";
$from = $_REQUEST['email'];
$headers = "From: $from";
$subject = "You have a message.";
$fields = array();
$fields{"email"} = "email";
$fields{"message"} = "message";
$body = "Here is what was sent:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$send = mail($to, $subject, $body, $headers);
?>
任何建议都非常受欢迎。我正在使用Html,jQuery和Php(Php仅用于表单)。我有问题,因为我已经更改了主机。我没有运气就试过类似的一些解决方案。也许我需要更新jQuery?
此致 ネ