我有一个基本的联系表格,它将用户的消息两次发送给显示该表格的公司:一次包含所有正确的信息,一次包含空白的文本字段,即列出了姓名、电子邮件、电话、消息但不包含信息。我已经研究了几个小时,但无法弄清楚。
在我页面的最顶部,我有这个标题:
<?php
ob_start();
session_start();
if( isset($_POST['submit'])) {
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
// Processing
header("Location:http://www.berrieswebdesign.com/business1 /thankyou.php?happymessage=thanks");
unset($_SESSION['security_code']);
} else {
// Error Message
header("Location:http://www.berrieswebdesign.com/business1 /thankyou.php?sadmessage=securitybreach");
unset($_POST['submit']);
}
} else {
}
ob_flush();
?>
Javascript:
$(function(){
$('#contact').validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
url: 'process.php',
success: function() {
$('#contact').hide();
$('#contact-form').append("<p class='thanks'>Thanks! Your request has been sent.</p>")
}
});
}
});
});
和 process.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);
mail("me@yahoo.com", "Inquiry", "Name: {$name}\n Email: {$email}\n Phone: {$phone}\n Message: {$message}\n");
?>
感谢您提前提供任何帮助。