|
发表于 2009-6-21 20:41:25
|
显示全部楼层
我用的1.7.1版自带的验证码插件,没出现报错呀.
function captcha()
{
$this->load->plugin('captcha');
$vals = array(
'word' => '',
'img_path' => './images/',
'img_url' => 'http://localhost/images/',
'font_path' => base_url().'system/fonts/texb.ttf',
'img_width' => '80',
'img_height' => 30,
'expiration' => 1
);
$cap = create_captcha($vals);
$this->session->set_userdata('code',$cap['word']);
return $cap;
}
视图: echo $cap['image'];
验证就粗略写下:
$this->form_validation->set_rules('code','验证码','callback_checkCode');
function checkCode($code)
{
if ($code==$this->session->userdata('code'))
{
return true;
}
else
{
$this->form_validation->set_message('checkCode', '%s输入错误');
return FALSE;
}
} |
|