Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Securimage

how to use Securimage in volt



42.3k
Accepted
answer

The question is kind of pointless, assuming you've read the Securimage quick start guide.

// form.volt
<form>
<img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image" />
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a>
</form>

That being said, if you want to integrate Securimage with Phalcon, you would do something like this:

  1. Register the securimage folder with the class loader
/// loader.php

// ...
$loader->registerDirs([
   <PUBLIC_DIR>.'/securimage/',
]);
// ...
  1. Explicitly start the session in controller action then validate
// MyController.php

// ...
public function formAction() {
   $this->session->start();
   if($this->request->has('captcha_code')) {
      $securimage = new Securimage();
      if($securimage->check($this->request->get('captcha_code')) == false) {
         / Client is probably a bot or clumsy human
      }
   }
}
// ...