Arrg。
我可以发现这种接触形式中的无休止的漏洞。 表格提交后,“比克”无休止地印刷。 我失踪了什么? 错误是没有的,还是错? (在工作档案中,通过<代码><script category=“text/javascript” src=“contact.js”></script>)
增 编
<?php
if(isset($_POST[ submitted ])) {
if(trim($_POST[ checking ]) !== ) {
$captchaError = true;
} else {
if(trim($_POST[ email ]) === ) {
$emailError = Please enter a valid email address ;
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+.[A-Z]{2,4}$", trim($_POST[ email ]))) {
$emailError = That s not a valid email address ;
$hasError = true;
} else {
$email = trim($_POST[ email ]);
}
}
if(!isset($hasError)) {
$emailTo = to email ;
$subject = site email ;
$body = "$email";
$headers = From: webmail ;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
} ?>
<script type="text/javascript">
$(document).ready(function() {
$( form#contactForm ).submit(function() {
$( form#contactForm .error ).remove();
var hasError = false;
$( .requiredField ).each(function() {
if($(this).hasClass( email )) {
var emailReg = /^([w-.]+@([w-]+.)+[w-]{2,4})?$/;
if(!emailReg.test(jQuery.trim($(this).val()))) {
var labelText = $(this).prev( label ).text();
$(this).parent().append( <span class="error"> <i>invalid email</i></span> );
hasError = true;
}
}
});
if(!hasError) {
$( #thanks ).fadeOut( normal , function() {
$(this).parent().append( <img src="../loading-small.gif" alt="Loading…" height="31" width="31" /> );
});
var formInput = $(this).serialize();
$.post($(this).attr( action ),formInput, function(data){
$( form#contactForm ).slideUp("fast", function() {
$(this).before( <p class="thanks"> <strong>增 编!</strong> );
$(".thanks").delay(3000).fadeOut();
});
});
}
return false;
});
});
</script>
<?php if(isset($emailSent) && $emailSent == true) { ?>
<div class="thanks"></div>
<?php } else { ?>
<form action="http://mysite.com" id="contactForm" method="post">
Sign up for email notification <input type="text" name="email" size="30" id="email" value="<?php if(isset($_POST[ email ])) echo $_POST[ email ];?>" class="requiredField email" />
<?php if($emailError != ) { ?><span class="error"><?=$emailError;?></span><?php } ?>
<input type="hidden" name="submitted" id="submitted" value="true" />
<button type="submit">Send</form>
<?php } ?>