验证码破坏了我的表单?
我已经在我的表单中实现了验证码,但它似乎没有得到验证。 我在下面添加了代码,以查看我的布局中是否有任何明显的内容以及如何修改它。 该帖子的公钥和私钥已被删除。
谢谢。
<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>
I have implemented a captcha in my form, but it doesn't seem to be validating. I have included code below to see if there is anything obvious in my layout and how I can go about modifying it. Public and private keys have been deleted for the post.
Thanks.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能说你的验证码有什么问题,因为我不知道这个验证码实现的具体细节。
由于您没有使用发布的数据填写字段,因此您的表单已重置。 也许你并不打算这样做。
首先确保您的表单在没有验证码的情况下按预期工作,以确保问题出在验证码中。
I cannot say what is wrong with your captcha, because I don't know the specifics of this captcha implementation.
Your form is reset because you do not fill the fields with posted data. Perhaps you do not intend to.
First make sure your form works as expected without the captcha, to make sure the problem is in the captcha.