我正试图在我正在开发的网站上的电子邮件表单中实现一个重述,但它不起作用,我不知道为什么。。。我已经删除了所有的重述代码,表单运行良好,我认为我的错误在于某个地方的重述处理,但我不确定。如有任何帮助,将不胜感激
这是表格
<!-- start contact form -->
<form method="POST" name="contact_form" action="contact-form-handler.php">
<h4>Your Name:</h4>
<input type="text" name="name" size="35">
<h4>Email Address:</h4>
<input type="text" name="email" size="35">
<h4>Message:</h4>
<textarea name="message" rows="6" cols="37"></textarea>
<div>
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=publickey">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=publickey"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
</div>
<div>
<input type="submit" value="Submit">
</div>
<script language="JavaScript">
var frmvalidator = new Validator("contact_form");
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email");
frmvalidator.addValidation("email","email","Please enter a valid email address");
frmvalidator.addValidation("message","req","Please write a message");
frmvalidator.addValidation("recaptcha_challenge_field", "req", "Please answer the captcha test");
</script>
</form>
<!-- end contact form-->
这是处理它的后端php…
<?php
require_once('/scripts/recaptcha/recaptchalib.php');
$privatekey = "PRIVATE KEY";
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
header('Location: contact.html')
exit;
} else {
$myemail = 'myemail';
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:'n Name: $name 'n ".
"Email: $email_address'n Message 'n $message";
$headers = "From: $myemail'n";
$headers .= "Reply-To: $email_address";
$email_body = wordwrap($email_body, 70);
mail($to,$email_subject,$email_body,$headers);
header('Location: contact_thanks.html');
exit;
}
?>
您必须在此处插入recatcha提供的密钥:src="http://www.google.com/recaptcha/api/challenge?k=publickey"
,此处插入src="http://www.google.com/recaptcha/api/noscript?k=publickey"
(用recatcha给出的公钥替换"公钥")
并将repatcha提供的私钥放在这里的php文件中:$privatekey = "PRIVATE KEY";
如果你仍然有问题,有时repatcha会生成无效的密钥,如果你不幸得到了坏掉的密钥,你必须等待一天左右才能修复。
要获得你的钥匙,如果你还没有这样做,请在这里注册
根据我自己的经验,非常重要的一点是,如果你的钥匙坏了,重述根本不会出现,你也不会出错!我不得不手动访问链接,以查看repatcha密钥会返回500内部服务器错误,我不得不等待他们修复这些密钥。