我有一个使用 Jquery 表单插件的基本联系表单。我无法使用插件提交它。仅当我将 php 包含添加到 process.php 时,它才会提交。
Javascript:
$(document).ready(function() {
$("#contact").validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
url:"process.php",
type:"post",
});
}
});
});
这是我的联系表格:
<form id="contact" method="post" name="validation" action="contact.php" onsubmit="return validateForm();">
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" placeholder="Full Name" title="Enter your name" class="required">
<label for="email">E-mail</label>
<input type="email" name="email" placeholder="yourname@domain.com" title="Enter your e-mail address" class="required email">
<label for="phone">Phone</label>
<input type="tel" name="phone" placeholder="ex. (555) 555-5555">
<label for="message">Question/Comment</label>
<textarea name="message"></textarea>
<input type="submit" name="submitted" class="button" id="submit" value="Send Message" />
</fieldset>
</form>
进程.php
<?php
function GetHeaders()
{
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Company Name<info@companyname.com>' . "\r\n";
return $headers;
}
// Get Data
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$phone = strip_tags($_POST['phone']);
$message = strip_tags($_POST['message']);
// Send Message
$headers = GetHeaders();
$intro = "\"Thank you for contacting Company Name. We are very interested in assessing your situation and will be in touch as soon possible.\" <br />
<br/>
Best Regards,<br/>
<br/>
Company<br/>
";
mail($email, "RE: Contact Form Submission", $intro, $headers);
?>
感谢您提前提供任何帮助。