我正在使用recaptcha。最初的错误是使用'die',但这把我带到另一个页面,给了我一个错误。
因为我想让它在页面中显示,所以我使用了print
echo的问题是函数不起作用:
这是我的网站:
http://www.the-big-bbq.co.uk/invitation.php prettyPhoto
我代码:<?php
if (isset($_POST['submit'])){
require_once('recaptchalib.php');
$privatekey = "6LeBwPcSAAAAAL2pNriaDSi8ca0Yb1qewzfDMYyY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
echo $myDiv1;
} else {
// Your code here to handle a successful verification
}
}
?>
这是html
<p class="myDiv1">Please enter the text shown</p>
最初使用的是:
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
如何使用echo,但只在他们输入错误的详细信息时显示它
在这种情况下,您需要做的就是用一个或多个echo
语句输出您想要的内容。
我不知道$myDiv1
是什么,所以我只是手工做的。
像这样:-
<?php
if (isset($_POST['submit'])){
require_once('recaptchalib.php');
$privatekey = "6LeBwPcSAAAAAL2pNriaDSi8ca0Yb1qewzfDMYyY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
echo '<p class="myDiv1">';
echo "The reCAPTCHA wasn't entered correctly. Go back and try it again.";
echo ' (reCAPTCHA said: ' . $resp->error . ')';
echo '</p>';
} else {
// Your code here to handle a successful verification
}
}
?>