how to create captcha in codeigniter 2.1.0 -


how create captcha in codeigniter 2.1.0 load helper codeigniter ? when have model m_captcha :

    function __construct() {             parent::__construct(); }      function setcaptcha()     {             $this->load->helper('captcha');             $vals = array(                 'img_path'          => './asset/captcha',                 'img_url'           => base_url().'/asset/captcha',                 'expiration'        => 3600,// 1 hour                 'font_path'     => './system/fonts/georgia.ttf',                 'img_width'     => '140',                 'img_height'        => 30,                 'word'          => random_string('numeric', 6),                 );              $cap = create_captcha($vals);             if ($cap)             {                     $capdb = array(                         'captcha_id'        => '',                         'captcha_time'      => $cap['time'],                         'ip_address'        => $this->ci->input->ip_address(),                         'word'              => $cap['word']                     );                     $query = $this->db->insert_string('captcha', $capdb);                     $this->db->query($query);             }else {                             return "captcha not work" ;                      }                  return $cap['image'] ; }         

and have controller c_login :

   function __construct() {     parent::__construct();     $this->load->model('m_captcha'); }         public function index()     {           $this->load->helper('captcha');           $data = $this->m_captcha->setcaptcha();                                       $this->load->view('login/v_form',$data);                             } 

and have view :

<?php echo form_open('c_login'); ?>  <?php echo  $cap['image']; ?> <?php echo form_error('captcha');?> <?php echo form_close(); ?> 

why captcha cannot show in view ? position folder , image captcha in sms/asset/captcha . sms folder root codeigniter.

<?php echo $cap['image']; ?> problem.

lets check flow once again, returning $cap['image'] model.

and after that, accepted in $data in controller.

it must $data['capcha'] can access using $capcha in view.

very simple.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -