[eluser]chmod[/eluser]
[quote author="ppopowicz" date="1246909769"]When I build a quick form and validation for the sig_key, I'm not running into any problems. Everything submits, and validates okay including trim, xss_clean, required and the callback function.
There is something else causing the error. After looking at the code again, you are using non-validated variables to make your calls to the databases. You are setting them ($username, $password, and $sig_key) before you even validate the data, you should be setting those AFTER you validate okay.
In your original code, where are you setting the sig_key to the session? If you aren't setting it at all the callback will fail.[/quote]
after set sig_key to the session using "http://192.168.134.135/sig/", then I validate it .
in view:
Code:
<?=form_open('center/login/ilogin');?>
<div class="dlu">
<div class="dlu1">
<div class="dlu1_1"><?=$this->lang->line('label_username');?></div>
<div class="dlu1_2">
<input id="input_username" name="input_username" type="text" value="" class="bc_ipt1" />
</div>
</div>
<div class="dlu1">
<div class="dlu1_1"><?=$this->lang->line('label_password');?></div>
<div class="dlu1_2">
<input id="input_password" name="input_password" type="password" value="" class="bc_ipt1" />
</div>
</div>
<div>
<span class="">验证码 :</span>
<span><input id="sig_key" name="sig_key" type="text" value="" /></span>
<span>
<a id="sig_refresh_img" name="sig_refresh_img" href="#">
<img alt="SIG" id="sig_img" name="sig_img" src="http://192.168.134.135/sig/" />
</a>
</span>
<span>
<a id="sig_refresh_text" name="sig_refresh_text" class="" href="#">refresh</a>
</span>
</div>
<div class="dlu2" id="submit">
<input type="image" src="<?=IMG_URL;?>center/bc3.jpg" />
</div>
</div>
<?=form_close();?>
the controller:
Code:
function ilogin(){
$username = $this->input->post('input_username');
$password = $this->input->post('input_password');
$sig_key = $this->input->post('sig_key');
//将表名存入session中
$tablename = $this->security_model->getMemberTableName($username);
$session_data = array('tablename' => $tablename);
$this->session->set_userdata($session_data);
$this->form_validation->set_rules('input_username','lang:label_username','trim|xss_clean|required|callback_checkUserPass');
$this->form_validation->set_rules('input_password','lang:label_password','trim|xss_clean|required');
$this->form_validation->set_rules('sig_key', 'lang:sig_key', 'trim|xss_clean|callback_checkSigKey');
if ($this->form_validation->run() === false){
$data = array('title' => $this->lang->line('page_title_login'));
$this->load->view('center/login_main_tpl', $data);
}else{
$pid = $this->security_model->getUserPid($username)->pid;
$md5password = $this->security_model->getUserPid($username)->md5Password;
$nickname = $this->security_model->getIdByPid($username)->nickname;
$exps = $this->security_model->getUserExps($username)->exps;
$goldCoins = $this->security_model->getUserGoldCoins($username)->goldCoins;
$credits = $this->security_model->getUserCredits($username)->credits;
$ranks = $this->security_model->getUserRanks( $exps );
$payType = $this->security_model->getUserPayType($username)->payTypeName;
$groupId = $this->security_model->getIdByPid($username)->groupId;
$session_data = array( 'session_id_saved' => $this->session->userdata('session_id'),
'username' => $username,
'pid' => $pid,
'md5password' => $md5password,
'nickname' => $nickname,
'exps' => $exps,
'goldCoins' => $goldCoins,
'credits' => $credits,
'ranks' => $ranks,
'payType' => $payType,
'groupId' => $groupId);
$this->session->set_userdata($session_data);
$forward = $this->session->userdata('forward');
if (!empty($forward)){
redirect($forward, 'refresh');
}else{
$username = $this->session->userdata('username');
$data = array( 'username' => $this->session->userdata('username'),
'nickname' => $nickname,
'credits' => $credits,
'ranks' => $ranks,
'goldCoins' => $goldCoins,
'serviceStartTime' => $this->security_model->getIdByPid($username)->serviceStartTime,
'serviceEndTime' => $this->security_model->getIdByPid($username)->serviceEndTime,
'totalFillTimes' => $this->security_model->getIdByPid($username)->totalFillTimes,
'payType' => $payType);
$this->load->view('center/mycenter_tpl',$data);
}
}
}