[eluser]zenixgrace[/eluser]
hi,
i'm a newbie in codeigniter
i'm use v 2.0.3
i try to use codeigniter captcha library
i got some error when i want to put in database
when i trace my code, i get a NULL value in my $cap['time'] and the others
here is my code controller
Code:
class Test extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('testlib');
}
function index()
{
$data['cap'] = $this->testlib->setCaptcha();
$this->load->view('home/index',$data);
}
}
here is my library code
Code:
class Testlib {
var $CI = NULL;
function __construct()
{
$this->CI =& get_instance();
$this->CI->load->library('encrypt');
}
function setCaptcha()
{
$this->CI->load->helper('captcha');
$vals = array(
'word' => random_string('alnum', 6),
'img_path' => $this->CI->config->item('captcha_path'),
'img_url' => $this->CI->config->item('captcha_url'),
'font_path' => './path/to/fonts/texb.ttf',
'img_width' => '140',
'img_height' => 30,
'expiration' => 3600 //one hour
);
$cap = create_captcha($vals);
$data = array(
'captcha_time' => $cap['time'],
'ip_address' => $this->CI->input->ip_address(),
'word' => $cap['word']
);
$query = $this->CI->db->insert_string('captcha', $data);
$this->CI->db->query($query);
return $cap;
}
}
i already set captcha path and url in my config.php
Code:
$config['captcha_path'] = './captcha/';
$config['captcha_url'] = $config['base_url'].'captcha/';
when i debug my code captcha didn't return anything..
$cap['time'] return NULL value
$cap['word'] return NULL value
and the image didn't show
is my code has wrong?
can someone explain me how can i fixed that?