| | 170 | } |
| | 171 | |
| | 172 | /** |
| | 173 | * Demontrates how to use the Captcha library. |
| | 174 | */ |
| | 175 | public function captcha() |
| | 176 | { |
| | 177 | // Form submitted |
| | 178 | if (isset($_POST['captcha_answer'])) |
| | 179 | { |
| | 180 | // Note: Captcha::valid() can be used in conjunction with the Validation library too |
| | 181 | echo (Captcha::valid($_POST['captcha_answer'])) ? 'Good answer!' : 'Wrong answer!'; |
| | 182 | } |
| | 183 | |
| | 184 | // Show form |
| | 185 | echo form::open(); |
| | 186 | echo '<p>'; |
| | 187 | echo Captcha::factory()->render(); // <-- shows the Captcha challenge (image/riddle/etc) |
| | 188 | echo '</p>'; |
| | 189 | echo form::input('captcha_answer'); |
| | 190 | echo form::submit(array('value' => 'Check')); |
| | 191 | echo form::close(); |