1

サインアップ ページでキャプチャ コードのセキュリティが必要ですが、フォームに間違ったキャプチャコードを入力してフォームを送信すると、問題は、サインアップ ページで 2 つのページを表示することです。このフォームに正しいキャプチャを再度入力しますが、同じ問題が再び発生し、誤ったキャプチャが表示されます。

コントローラ

public function user_signup($data = NULL){
                $this->load->library('form_validation');
                $this->recaptcha->recaptcha_check_answer($_SERVER['REMOTE_ADDR'],$this->input->post('recaptcha_challenge_field'),$this->input->post('recaptcha_response_field'));

                $this->form_validation->set_rules('Username', 'Username', 'required|trim|is_unique[users.Username]');
                $this->form_validation->set_rules('First_name', 'First Name', 'required|trim');
                $this->form_validation->set_rules('Last_name', 'Last Name', 'required|trim');
                $this->form_validation->set_rules('Email', 'Email', 'required|trim|valid_email');
                $this->form_validation->set_rules('Password', 'Password', 'required|trim|md5');
                $this->form_validation->set_rules('Conf_password', 'Confirm Password', 'required|trim|matches[Password]');
                $this->form_validation->set_message('is_unique', 'Username already exists.');
                if($this->form_validation->run() && $this->recaptcha->getIsValid()){
                    //Call to recaptcha to get the data validation set within the class. 

                    $form_data = array();
                        $form_data['Username'] = $this->input->post('Username');
                        $form_data['First_name'] = $this->input->post('First_name');
                        $form_data['Last_name'] = $this->input->post('Last_name');
                        $form_data['Email'] = $this->input->post('Email');
                        $form_data['Password'] = $this->input->post('Password');
                        $form_data['Conf_password'] = $this->input->post('Conf_password');

                        $this->load->model('User');
                        $this->User->sign_up($form_data);
                        $data['msg']= "Account Created Sucessfuly";

                       }else{
                        if(!$this->recaptcha->getIsValid()){
                        $this->session->set_flashdata('error','incorrect captcha');                     
                        }
                    }

                redirect("Users/signup", $data);
        }

モデル

public function sign_up($form_data){
       $this->db->insert('users', $form_data);
}

見る

                            <?php
                            //$val = NULL;
                            if(isset($results->id)){
                                $val = "Update";
                                $action = "Users/user_update/".$results->id;
                            }else{
                                $val= "Register";
                                $action = "Users/user_signup";
                            }; ?>

                            <?php echo form_open($action); ?>
                            <?php echo form_input(array('name'=>'Username', 'class'=>'input-xlarge', 'type'=>'text', 'placeholder'=>'Username', 'required' => 'required', 'value'=>$u)); ?>
                            <?php echo form_error('Username', '<div class="alert alert-error">', '</div>'); ?>
                            <?php echo form_input(array('name'=>'First_name', 'class'=>'input-xlarge', 'type'=>'text', 'placeholder'=>'First Name', 'required' => 'required', 'value'=>$f)); ?>
                            <?php echo form_error('First_name', '<div class="alert alert-error">', '</div>'); ?>
                            <?php echo form_input(array('name'=>'Last_name', 'class'=>'input-xlarge', 'type'=>'text', 'placeholder'=>'Last Name', 'required' => 'required', 'value'=>$l)); ?>
                            <?php echo form_error('Last_name', '<div class="alert alert-error">', '</div>'); ?>
                            <?php echo form_input(array('name'=>'Email', 'class'=>'input-xlarge', 'type'=>'text', 'placeholder'=>'Email', 'required' => 'required', 'value'=>$e)); ?>
                            <?php echo form_error('Email', '<div class="alert alert-error">', '</div>'); ?>
                            <?php echo form_input(array('name'=>'Password', 'class'=>'input-xlarge', 'type'=>'password', 'placeholder'=>'Password')); ?>
                            <?php echo form_error('Password', '<div class="alert alert-error">', '</div>'); ?>
                            <?php echo form_input(array('name'=>'Conf_password', 'class'=>'input-xlarge', 'type'=>'password', 'placeholder'=>'Confirm Password')); ?>                           
                            <?php echo form_error('Conf_password', '<div class="alert alert-error">', '</div>'); ?>

                            <?php if(!isset($results->id)){echo $recaptcha_html;} ?>
                            <?php if ($this->session->flashdata('error') !== FALSE) { echo '<div class="alert alert-error">'.$this->session->flashdata('error').'</div>'; } ?>
                         <div class="login-actions">                           
                             <span><input type="checkbox"> <span class="remember">I have read & agree</span></span>                 
                             <span><?php echo form_submit(array('value'=>$val, 'class'=>'btn btn-large btn-warning pull-right', 'type'=>'submit')); ?></span>
                        </div>
                    <?php echo form_close(); ?>
4

2 に答える 2