donglao9606 2011-04-08 16:13
浏览 74
已采纳

CodeIgniter reCaptcha麻烦

Okay all, I have seen similar questions asked on this site, but they don't have all the handholding details I'm looking for on this particular issue!

I am in limbo between using the JS version of reCaptcha and a PHP version made for CodeIgniter 1.7.1

With the JS version I have it displayed within the generated HTML but I'm not sure how to get the proper result passed through to the PHP form. The surrounding form currently only posts in the PHP whether there was "any" text input, not if it was proper text. I can monitor the captcha text input field to see if anything was submitted, but this doesn't check the actual javascript for a proper result. I need a PHP function call that can get a call from the HTML that the javascript generates with Recaptcha.create.

You might be thinking: Since codeigniter is PHP why not just use the PHP version of recaptcha? Well the CodeIgniter structure is the most unintuitive PHP and MVC structure I've dealt with. Finding the necessary function calls on this site I am editing has turned into a reverse engineering exercise.

I also have a PHP version, made here https://github.com/seanmcgary/Codeigniter-ReCaptcha, and just like in classic CodeIgniter flavor, the documentation is basically nonexistent. I know that version is for CodeIgniter 1.7, but I don't know what version of reCaptcha it is.

Please don't link me to the codeigniter wiki, just relevant assistance.

It is becoming convoluted to work on implementing the JS version, and parts of a PHP version because one version might be more practical. So I'm asking you guys, thanks!

  • 写回答

2条回答 默认 最新

  • dongling0519 2011-04-08 23:02
    关注

    This wiki article and library are extremely simple. Because you don't want just a link here is some sample code from the wiki article to get you started.

    The code is really quite self explanatory. Set up your config with your public and private keys, then in your controller load the recaptcha & form_validation libraries and show the proper view depending on the status of the validation.

    config/recaptcha:

    $config['recaptcha'] = array(
      'public'=>'YOUR PUBLIC KEY',
      'private'=>'YOUR PRIVATE KEY',
      'RECAPTCHA_API_SERVER' =>'http://www.google.com/recaptcha/api',
      'RECAPTCHA_API_SECURE_SERVER'=>'https://www.google.com/recaptcha/api',
      'RECAPTCHA_VERIFY_SERVER' =>'www.google.com',
      'RECAPTCHA_SIGNUP_URL' => 'https://www.google.com/recaptcha/admin/create',
      'theme' => 'white'
    );
    

    controller:

    function index()
      {
        $this->load->library('recaptcha');
        $this->load->library('form_validation');
        $this->lang->load('recaptcha');
        $this->load->helper('form');
    
        if ($this->form_validation->run()) 
        {
          $this->load->view('recaptcha_demo',array('recaptcha'=>'Yay! You got it right!'));
        }
        else
        {
          //the desired language code string can be passed to the get_html() method
          //"en" is the default if you don't pass the parameter
          //valid codes can be found here:http://code.google.com/apis/recaptcha/docs/customization.html#i18n
          $this->load->view('recaptcha_demo',array('recaptcha'=>$this->recaptcha->get_html()));
        }
      } 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题