Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://codeigniter.com/wiki/ReCAPTCHA/" rel="nofollow">This wiki article and library are extremely simple</a>. Because you don't want just a link here is some sample code from the wiki article to get you started. </p> <p>The code is really quite self explanatory. Set up your config with your public and private keys, then in your controller load the recaptcha &amp; form_validation libraries and show the proper view depending on the status of the validation.</p> <p><strong>config/recaptcha:</strong> </p> <pre><code>$config['recaptcha'] = array( 'public'=&gt;'YOUR PUBLIC KEY', 'private'=&gt;'YOUR PRIVATE KEY', 'RECAPTCHA_API_SERVER' =&gt;'http://www.google.com/recaptcha/api', 'RECAPTCHA_API_SECURE_SERVER'=&gt;'https://www.google.com/recaptcha/api', 'RECAPTCHA_VERIFY_SERVER' =&gt;'www.google.com', 'RECAPTCHA_SIGNUP_URL' =&gt; 'https://www.google.com/recaptcha/admin/create', 'theme' =&gt; 'white' ); </code></pre> <p><strong>controller:</strong></p> <pre><code>function index() { $this-&gt;load-&gt;library('recaptcha'); $this-&gt;load-&gt;library('form_validation'); $this-&gt;lang-&gt;load('recaptcha'); $this-&gt;load-&gt;helper('form'); if ($this-&gt;form_validation-&gt;run()) { $this-&gt;load-&gt;view('recaptcha_demo',array('recaptcha'=&gt;'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-&gt;load-&gt;view('recaptcha_demo',array('recaptcha'=&gt;$this-&gt;recaptcha-&gt;get_html())); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COOkay, I have that set up already but I'm not sure how that works with the rest of the form. There is a name field, email, phone number - these are checked to see if there is any content in them, I need the condition to also get the value from the recaptcha code. Can I just copy the $this->load->library functions? Also I don't have anything in a folder named helper or a file named form in that nonexistant folder
      singulars
    2. COThe form helper is [a built in helper](http://codeigniter.com/user_guide/helpers/form_helper.html). I'm getting the impression you don't understand how the [form validation](http://codeigniter.com/user_guide/libraries/form_validation.html) class works. You need to set your rules such as `$this->form_validation->set_rules('email', 'Email', 'required');` and if they all validate then `$this->form_validation->run()` will return true. The documentation has a great explanation for how it works, with examples.
      singulars
    3. COOkay. So I download the code. Move all the files to the appropriate folders. Set the keys in the config/recaptcha.php file. Then where I have my form submit logic I put in the $this->form_validation->run() function. Then in the HTML I do what?? I need to display the captcha for user input. I see google's code for adding the php recaptcha into non-code igniter documents, but I'm not sure which parts of that are relevant. And I'm not sure how I'm supposed to be making calls to particular files. Right now I have
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload