public function captchahelper() {
$helper=array('html','url','string','captcha','form','security');
$this->load->helper($helper);
$this->load->library('form_validation');
$this->load->model('model_captcha');
$random_word = random_string('alpha',5);
$vals = array(
'word' => $random_word,
'img_path' => './captcha/',
'img_url' => base_url().'captcha/',
'font_path' => './assets/fonts/arial.ttf',
'img_width' => '150',
'img_height' => '35',
'expiration' => '7200',
'font_size' => '16',
'colors' => array(
'background' => array(255, 255, 255),
'border' => array(255, 0, 0),
'text' => array(0, 0, 0),
'grid' => array(255, 40, 40)
)
);
$img = create_captcha($vals);
$captcha_data = array(
'captcha_time' => $img['time'],
'ip_address' => $this->input->ip_address() ,
'word' => $img['word'],
);
$data['captcha']= $img;
$this->form_validation->set_rules('captcha','Captcha','required|trim');
if ($this->form_validation->run() ==FALSE){ //if any of the above validation fails
$data['title']= "DIRECTORY HELPER"; //in view $title
$data['page_header'] = '<strong>Directory helper in codeigniter</strong>';
$this->load->view('captchaHelper', $data);
}else {
$input = xss_clean($_POST['captcha']);
$word = $img['word'];
echo "word is of type: ".gettype($word);
echo br();
echo "POST is of type: ".gettype($input);
echo br(2);
echo $comp = strcmp($input, $word);
echo br();
echo ($input === $word)? 'Match!' : 'NOT A MATCH!';
}
}
I am new to codeigniter. I checked the variables are of the same type and values and yet when compare. it returns the 'NOT A MATCH' message.
please help