我已经在我的表单中实现了一个验证码,但它似乎没有得到验证。我在下面包含了代码,以查看我的布局中是否有任何明显的内容以及如何进行修改。该帖子的公钥和私钥已被删除。
谢谢。
<h1>Contact</h1>
<form action="index.php" method="post">
<input type="hidden" name="required_fields" value="name, email, message" />
<input type="hidden" name="email_fields" value="email" />
<input type="hidden" name="html_template" value="form.tpl.html" />
<input type="hidden" name="mail_template" value="mail.tpl.txt" />
<input type="hidden" name="thanks" value="/thanks.php" />
<!-- <input type="hidden" name="error_page" value="./docu/error.html" /> -->
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td><p>Full Name <span>*</span></p></td>
<td> </td>
<td><input type="text" name="name" value="" size="40" /></td>
</tr>
<tr valign="bottom">
<td><p>Phone</p></td>
<td> </td>
<td><input type="text" name="phone" value="" size="40" />
</td>
</tr>
<tr valign="bottom">
<td><p>Email <span>*</span></p></td>
<td> </td>
<td><input type="text" name="email" value="" size="40" />
</td>
</tr>
<tr valign="top">
<td><p>Message <span>*</span></p></td>
<td> </td>
<td><textarea name="message" cols="30" rows="10"></textarea></td>
</tr>
<tr valign="top">
<td> </td>
<td> </td>
<td><p>
<?php
require_once('recaptchalib.php');
// Get a key from http://recaptcha.net/api/getkey
$publickey = "";
$privatekey = "";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
}
}
echo recaptcha_get_html($publickey, $error);
?>
<input type="submit" name="send" value="Send" />
<br />
<span>*</span> = required field.</p></td>
</tr>
</table>
</form>