Just wrote a captcha validator tool - behavior & a helper to implement captcha quite fast. Here's what you'll do to add captcha verification:
In your controller, lets say I need captcha in registration form.
users_controller.php
PHP:
-
Function register()
-
{
-
$this->pageTitle ='User Registration';
-
// goes on…
-
$this->User->enableCaptcha(); // this function will initialize the captcha code
-
}
In the view, register.ctp
PHP:
-
<? // line below will generate the image and the input field as well ?>
-
</form>
After data is posted through the form, it goes to beforeSave() of my behavior which takes care of the validating and showing up the error in case.
This is the part of my UserContent behavior which will have some more cool shortcuts. Will post them in a while..
- Abhimanyu Grover
Leave A Reply