我正在制作ajax表格。我得到了成功的消息,但我没有收到任何电子邮件,任何想法?
发送-form.php的:
<?php
// Email Submit
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['email']) && isset($_POST['name']) && isset($_POST['text']) && isset($_POST['email'])) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
//send email
mail( "mymail@email.com", "Contact Form: ".$_POST['name'], $_POST['text'], "From:" . $_POST['email'] );
}
?>
functions.js:
$(function() {
// Contact Form
$("#contact").submit(function(e){
e.preventDefault();
var name = $("#name").val();
var email = $("#email").val();
var text = $("#text").val();
var dataString = 'name=' + name + '&email=' + email + '&text=' + text;
$("#contact").validate({
submitHandler: function(form) {
$.ajax({
type: "POST",
url: "send-form.php",
data: dataString,
success: function(){
$('.success').fadeIn(1000);
}
});
}
})
return false;
});
});
的index.html:
<form id="contact" method="post">
<fieldset>
<label>Your Name</label><br />
<input name="name" id="name" type="text">
<label>Your Email</label><br />
<input name="email" id="email" type="text">
<label>Your Question</label><br />
<textarea rows="10" name="text" id="text" ></textarea>
</fieldset>
<input type="submit" value="Send Message" name="submit">
<p class="success" style="display:none">Your message has been sent successfully.</p>
<p class="error" style="display:none">E-mail must be valid and message must be longer than 100 characters.</p>
</form>
我几个小时一直在选址,试图用我自己的技巧编辑它,但没有成功。这是我到目前为止所得到的。我收到了成功消息,但没有发送电子邮件给我。
感谢任何帮助!