[eluser]alectrash[/eluser]
I am creating a page with a form in that I want to use freakauth light in for validation.
In view i have:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<head>
</head>
<body>
<h1>Content</h1>
<h3><a name="leavecomment">Leave a comment</a></h3>
<?=form_open('/test/')?>
<label for="commentname">Name: </label><br /><?=form_input(array('name'=>'commentname',
'id'=>'commentname',
'maxlength'=>'120',
'size'=>'35',
'value'=>$this->validation->commentname ))?><br />
<span><?=(isset($this->validation) ? $this->validation->{'commentname'.'_error'} : '')?></span><br />
<label for='comment'>Comment: </label><br /><?=form_textarea(array('name'=>'comment',
'id'=>'comment',
'rows'=>'10',
'cols'=>'50',
'value'=>$this->validation->comment ))?><br />
<span><?=(isset($this->validation) ? $this->validation->{'comment'.'_error'} : '')?></span><br />
<!--CAPTCHA (security image)-->
<?php
if ($this->config->item('FAL_use_captcha_comment'))
{?>
<?=$this->load->view($this->config->item('FAL_captcha_img_tag_view'), null, true)?>
<label for="security"><br /><?=$this->lang->line('FAL_captcha_label')?>:</label><br />
<?=form_input(array('name'=>'security',
'id'=>'security',
'maxlength'=>'45',
'size'=>'45',
'value'=>''))?>
<?=(isset($this->validation) ? $this->validation->{'security'.'_error'} : '')?>
<?php }?>
<!-- END CAPTCHA (security image)-->
<?=form_submit('mysubmit', 'Add Comment');?>
</body>
</html>
In controller I have:
Code:
<?php
class Test extends Controller
{
function Test()
{
parent::controller();
//load fal library
$this->load->library('FAL_front', 'fal_front');
$this->load->library('FAL_validation');
$this->load->library('Freakauth_light');
$this->load->config('freakauth_light');
}
function index()
{
//load validation library
$this->load->library('validation');
$this->validation->set_error_delimiters("<div class='error'>", "</div>");
//set validation rules
$rules['comment'] = "required|min_length[4]|max_length[400]";
$rules['security'] = 'required|matches[captcha]';
$rules['commentname'] = 'required|min_length[2]|max_length[50]';
//just use login action for sake of it
$action = '_comment';
$this->freakauth_light->captcha_init($action);
$data['captcha'] = $this->config->item('FAL_captcha_image');
$this->validation->set_rules($rules);
//set fields to validate
$fields['comment'] = "comment";
$fields['security'] = "security";
$fields['commentname'] = "commentname";
$this->validation->set_fields($fields);
if($this->validation->run() == FALSE)
{
$this->load->view('test_view', $data);
}
else
{
$this->load->view('test_view', $data);
}
}
}
?>
Also in freakauthlight config i have ammended like so:
Code:
/*
|------------------------------------------------------------------------------
| Whether to use CAPTCHA (security code) functionality for those processes
|------------------------------------------------------------------------------
*/
$config['FAL_use_captcha_login'] = FALSE;
$config['FAL_use_captcha_register'] = TRUE;
$config['FAL_use_captcha_forgot_password'] = TRUE;
$config['FAL_use_captcha_comment'] = TRUE;
I just dont understand whats going on. When I look in the CI_SESSIONS table, the captcha value is the same as what is being generated on screen but then validation for the captcha always fails.
Has anybody experienced this before or have any ideas, ben racking my brain for months now.