Zend Captcha

Controller

include_once("Zend/Captcha/image.php");
include_once("Zend/loader.php");

$captcha = new Zend_Captcha_Image();
 $captcha->setWordLen('4')
 ->setHeight('60')
 ->setFont('arial.ttf')
 ->setImgDir('captcha')
 ->setDotNoiseLevel('5')
 ->setLineNoiseLevel('5');

if ($captcha->isValid($this->_request->getPost('captcha')))
 {
...
}

$captchaId = $captcha->generate();
 $this->view->captchaId = $captchaId;

 

views

<img src="/captcha/<?php echo $this->captchaId; ?>.png" alt="captcha">

<input type="text" class="form-control input-sm" name="captcha[input]" id="captcha" placeholder="Masukan kode keamanan ..." required="required">
 <input type="hidden" value="<?php echo $this->captchaId?>" name="captcha[id]" />

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s