0

我最近有一个为我设计的网站,但我的开发人员使用了一个非常糟糕的通用验证码,一半时间都失败了。我正在尝试使用 recaptcha 替换它,但我遇到了麻烦。我无法弄清楚哪个 *.php 用于“处理”,哪个用于“表单”。

我不想发布整个代码,所以这里是:

这是“表单”页面,因为它嵌入了表单字段等:http: //dl.dropbox.com/u/45666699/formcode.txt

有人可以看看这段代码并告诉我应该将私人代码放在哪里进行recaptcha?另外,如何禁用已安装的“random_number”验证码?谢谢!

4

2 回答 2

0

您现有验证码的代码已上线295, 296 and 297

require_once('recaptchalib.php');
$publickey = "6LfIUdISAAAAAKguxgdPCjZ6-OkVeu5tmcBaa7ug"; // you got this from the signup page
echo recaptcha_get_html($publickey);
于 2012-06-05T15:01:35.800 回答
0

好吧,当您尝试验证是否输入了正确的验证码时(即在您处理表单提交时),您将需要私钥

通过查看您的代码应该立即开始line 4

使用我不久前做的一个项目,你会有类似的东西......

$recaptcha_error = NULL;
//set it to NULL initially
if(isset($_POST["btnsend"])){
    include_once(INCLUDES_FOLDER."recaptcha-php-1.11/recaptchalib.php");
    $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
    if($resp->is_valid){
        //captch was gotten correctly
        //continue with your normal code processing here
    } else {
        //wrong input -- captch was invalid -- give the person the error response
        //mine is as below -- my usual way :)
        $response = array(array("Something seems to be wrong with the captcha!","Please check that you entered it correctly or check the returned error message"),false,"w");
        $recaptcha_error = $resp->error;
        //make sure to do the above so u can use it when generating the captcha display
    }
}


//You got the recaptch error (or left it as NULL above so you could do this)
//when generating your captch display as done on your lines 295, 296, 297
include_once(INCLUDES_FOLDER."recaptcha-php-1.11/recaptchalib.php");
echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY,$recaptcha_error);

希望这会有所帮助(即使有点):)
干杯

于 2012-06-05T15:39:55.113 回答