【问题标题】:I need help getting recaptcha to work我需要帮助让 recaptcha 工作
【发布时间】:2012-06-05 23:39:55
【问题描述】:

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

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

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

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

【问题讨论】:

  • 我想你把这个网站误认为是 vWorker 或 elance

标签: php security captcha


【解决方案1】:

您现有的验证码在线295, 296 and 297

require_once('recaptchalib.php');
$publickey = "6LfIUdISAAAAAKguxgdPCjZ6-OkVeu5tmcBaa7ug"; // you got this from the signup page
echo recaptcha_get_html($publickey);

【讨论】:

    【解决方案2】:

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

    通过查看您的代码应该在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);
    

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

    【讨论】:

      猜你喜欢
      • 2017-09-22
      • 2015-02-11
      • 2011-02-25
      • 2014-10-10
      • 2020-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多