Welcome Guest, Not a member yet? Register   Sign In
how to fix this error?
#9

[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">&lt;?=$this->lang->line('label_username');?&gt;</div>
            <div class="dlu1_2">
                &lt;input id="input_username" name="input_username" type="text" value="" class="bc_ipt1" /&gt;
            </div>
        </div>
        <div class="dlu1">
            <div class="dlu1_1">&lt;?=$this->lang->line('label_password');?&gt;</div>
            <div class="dlu1_2">
                &lt;input id="input_password" name="input_password" type="password" value=""  class="bc_ipt1" /&gt;
            </div>
        </div>
        <div>
            <span class="">验证码&nbsp;:</span>
            <span>&lt;input id="sig_key" name="sig_key" type="text" value="" /&gt;&lt;/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">
            &lt;input type="image" src="&lt;?=IMG_URL;?&gt;center/bc3.jpg" /&gt;
        </div>
    </div>
&lt;?=form_close();?&gt;


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);
            }
        }
     }


Messages In This Thread
how to fix this error? - by El Forum - 07-06-2009, 04:08 AM
how to fix this error? - by El Forum - 07-06-2009, 04:28 AM
how to fix this error? - by El Forum - 07-06-2009, 06:32 AM
how to fix this error? - by El Forum - 07-06-2009, 07:12 AM
how to fix this error? - by El Forum - 07-06-2009, 07:35 AM
how to fix this error? - by El Forum - 07-06-2009, 07:50 AM
how to fix this error? - by El Forum - 07-06-2009, 08:27 AM
how to fix this error? - by El Forum - 07-06-2009, 08:49 AM
how to fix this error? - by El Forum - 07-06-2009, 09:03 PM
how to fix this error? - by El Forum - 07-07-2009, 06:55 AM
how to fix this error? - by El Forum - 07-07-2009, 08:38 AM
how to fix this error? - by El Forum - 07-07-2009, 10:28 AM
how to fix this error? - by El Forum - 07-07-2009, 09:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB