我有一个使用javascript进行验证的联系表单。
有两个网站:
和
UES上的表格有效。 TEP上的表格没有。
两种形式都是一样的。 两种形式都是三个文件,代码如下:
的index.php:
<div class="FormLayout">
<script type="text/javascript">
$(function() {
$("#contact-us-form button").click(function() {
$('#ValidationMessages').hide();
$('#SubmitSuccess').hide();
$('.validationerror').removeClass('validationerror');
$.post("processing.php", $("#contact-us-form").serialize(), function(data) {
if($('status', data).text() == "missingFields") {
$('#ValidationMessages ul').text('');
$('messages message', data).each(function(index, label) {
$('#ValidationMessages ul').append('<li>' + $(label).text() + '</li>');
var field = $(label).attr('field');
$('label[for="' + field + '"]').addClass("validationerror");
$('input[name="' + field + '"]').addClass("validationerror");
$('select[name="' + field + '"]').addClass("validationerror");
$('textarea[name="' + field + '"]').addClass("validationerror");
$('.formvalue_' + field).addClass("validationerror");
});
$('#ValidationMessages').show();
} else if($('status', data).text() == "success") {
$('#SubmitSuccess').show();
document.getElementById('contact-us-form').reset();
}
}, "xml");
});
});
</script>
<form action="#" method="post" id="contact-us-form">
<label for="cname">Full Name</label>
<div style="height: 10px;">
</div>
<input type="text" name="cname" class="input input_wide" maxlength="250" />
<div style="height: 10px;">
</div>
<label for="cemail">Email</label>
<div style="height: 10px;">
</div>
<input type="text" name="cemail" class="input input_wide" maxlength="250" />
<div style="height: 10px;">
</div>
<label for="caccount">Account Number</label>
<div style="height: 10px;">
</div>
<input type="text" name="caccount" class="input input_wide" maxlength="10" />
<div style="height: 10px;">
</div>
<label for="cphone">Phone</label>
<div style="height: 10px;">
</div>
<input type="text" name="cphone" class="input input_wide" maxlength="50" />
<div style="height: 10px;">
</div>
<label for="cquestion">Message</label>
<div style="height: 10px;">
</div>
<textarea name="cquestion" rows="5" cols="28" class="input input_wide"></textarea>
<div style="height: 10px;">
</div>
<button class="button button-submit" type="button"> <span>Submit</span> </button>
</form>
processing.php:
<?php
include(substr($_SERVER["SCRIPT_FILENAME"],0,(strlen($_SERVER["PHP_SELF"]) * -1)) . "/templates/xhr_prepend.php");
include(_CODEDIR . '/TEP/Forms/Contact/Contact_processing.php');
?>
Contact_processing.php:
<?php
header("Content-Type: text/xml");
// Include Util Class
include(_CODEDIR . '/shared/Util.inc.php');
$validationFailed = false;
$validationMessages = array();
if(trim($_POST['cname']) == '') {
$validationFailed = true;
$validationMessages['cname'] = "Please provide your Full Name.";
}
if(trim($_POST['cemail']) == '') {
$validationFailed = true;
$validationMessages['cemail'] = "Please provide your Email address.";
} else {
if(preg_match("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/", $_POST['cemail']) == 0) {
$validationFailed = true;
$validationMessages['cemail'] = "Please provide a valid Email address.";
}
}
if(trim($_POST['caccount']) != '') {
if(preg_match("/^[0-9]{10}$/", $_POST['caccount']) == 0) {
$validationFailed = true;
$validationMessages['caccount'] = "Please provide a valid 10 digit Account Number.";
}
}
if(trim($_POST['cphone']) == '') {
$validationFailed = true;
$validationMessages['cphone'] = "Please provide your Phone number.";
}
if(trim($_POST['cquestion']) == '') {
$validationFailed = true;
$validationMessages['cquestion'] = "Please provide a Message.";
}
print '<Processing>';
if($validationFailed) {
print '<status>missingFields</status>';
print '<messages>';
foreach($validationMessages as $key => $val) {
print '<message field="' . Util::strCleanOutput($key). '">' . Util::strCleanOutput($val) . '</message>';
}
print '</messages>';
} else {
$emailBody = '<p><b>Contact Us Request</b></p>';
$emailBody .= '<b>Full Name:</b> ' . Util::strCleanOutput($_POST['cname']) . '<br />';
$emailBody .= '<b>Email:</b> ' . Util::strCleanOutput($_POST['cemail']) . '<br />';
if(trim($_POST['caccount']) == '') {
$emailBody .= '<b>Account Number:</b>Not Provided<br />';
} else {
$emailBody .= '<b>Account Number:</b> ' . Util::strCleanOutput($_POST['caccount']) . '<br />';
}
$emailBody .= '<b>Phone:</b> ' . Util::strCleanOutput($_POST['cphone']) . '<br />';
$emailBody .= '<b>Message:</b><br />' . nl2br(Util::strCleanOutput($_POST['cquestion'])) . '';
Util::SendMail("sa45762@tep.com", "webmaster@tep.com", "Contact Us - TEP", $emailBody);
print "<status>success</status>";
}
print '</Processing>';
?>
以下任何一个站点的代码都没有区别:
UES:
权限设置为:RWX
TEP:
权限设置为:RW
我认为这是一个权限问题,因为TEP的联系表单未设置为执行。
有什么想法吗?谢谢。 :)