Friday, March 16, 2012

Showing only integers for the captcha in codeigniter

I need to show 3 integer digits for my captcha in codeigniter site. I used the following for it and succeeded.

$aCaptchaCfg = array(
           'word'          => rand(111,999),   
            'img_path'   => './captcha/', 
            'img_url'       => site_url().'captcha/',
            'font_path'  => site_url().'./system/fonts/',
            'fonts'         => array('texb.ttf', 'TSCu_Comic.ttf'),
            'font_size'     => 25,     
            'img_width'  => '180', 
            'img_height' => '60',  
            'expiration' => 7200
            );

$aCaptcha = create_captcha($aCaptchaCfg);?>
Submit the word you see below
<?php
echo $aCaptcha['image'];
?>
<input type="text" name="captchafld" value="" />
     
<input type="hidden" name="Captcha" value="<?php echo $aCaptcha['word']; ?>">

No comments:

Post a Comment