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条)

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名