Welcome Guest, Not a member yet? Register   Sign In
SOLVED - FORM VAL / SESSION, more than one error page two errors out??
#1

[eluser]RJ[/eluser]
Hello,

I have a multi-page form, the controller code is below. Upon success your taken to page two. The problem is if a user makes an error more than once, then the site errors out, and I can not get a successful screen again. In many cases the entire site is down for a period of time, or if I open another browser, I can run through again unless error more than once, then same issue; i'm thinking it might have something to do with how I am handling sessions.. code below your input is gre

I could really use a hand figuring this out if you have any idea.



First we assign dealer to set template skin, then default page.
Code:
function device($dealer = '999', $page = 'personal_information')
    {
        $this->benchmark->mark('code_start');
        // start benchmarking
        
        # Load stuff
        $this->load->helper(array('form'));                    // load helpers
        $this->load->library('form_validation');            // load libraries    
        $this->form_validation->set_error_delimiters('<pre class="alert">', '</pre>');
        $this->load->model('dealer_model','dealer');        // load dealer
        $this->load->model('suw_model', 'suw');                // load suw
        $this->load->model('common_model', 'common');        // load common
        $this->lang->load('suw_main');                        // load language
        
        # Set dealer params
        $this->dealer->set_dealer($dealer);        // passes db info to dealer model for processing
        $this->load->model('Trimtrac_model', 'trimtrac');    
        
        switch($page)
        {
            case "personal_information":
            default:
                $this->page_one();
                break;
            
            case "plan_information":
                $this->page_two();
                break;
        }
                
        // end benchmarking
        $this->benchmark->mark('code_end');
    }

If not errors we add data to a session then proceed to page 2
Code:
function page_one()
    {
        // Set langauge for error messages
        $this->lang->load('form_validation');

        // Validation Check: rules are managed in the config/form_validation.php file
        if ($this->form_validation->run('device') == FALSE)
        {    
            // Build the page
            $page = 'page_one';
            $data['css'] = $this->common->set_css();
            $data['nav'] = $this->suw->navigation($page);
            $data['round_start'] = $this->common->round_start();
            $ctyarr = array();
            $cdata = $this->suw->country_generator($this->dealer->countries,$this->lang->lang());
            $ctyarr['countries'] = $cdata;
            $data['content']    =    $this->load->view('device_one',$ctyarr, TRUE);
            $data['sidebar'] = "Side bar here";
            $data['round_end'] = $this->common->round_end();
            $data['footer'] = "Footer";
            $data['google'] = $this->load->view('google','', TRUE);
            
            // write to template
            $this->template->write('title', '');
            $this->template->write('css', $data['css']);
            $this->template->write('nav', $data['nav']);
            $this->template->write('round_start', $data['round_start']);
            $this->template->write('content', $data['content']);
            $this->template->write('sidebar', $data['sidebar']);
            $this->template->write('round_end', $data['round_end']);
            $this->template->write('footer', $data['footer']);
            $this->template->write('google', $data['google']);
            
            // render page
            $this->template->render();
        }
        else
        {
            // make sure session is empty
            $this->session->sess_destroy();
            // build session
            $session = array(
                        'country' => $this->input->post('country'),
                        'MSISDN' => $this->input->post('MSISDN'),
                        'UNITID' => $this->input->post('UNITID'),
                        'FirstName' => $this->input->post('FirstName'),
                        'LastName' => $this->input->post('LastName'),
                        'M_COMP' => $this->input->post('M_COMP'),
                        'MC_vatnr' => $this->input->post('MC_vatnr'),
                        'StreetShipAddress1' => $this->input->post('StreetShipAddress1'),
                        'CityShip' => $this->input->post('CityShip'),
                        'postcode' => $this->input->post('postcode'),
                        'email' => $this->input->post('email'),
                        'vemail' => $this->input->post('vemail'),
                        'password' => $this->input->post('password'),
                        'vpassword' => $this->input->post('vpassword'),
                        'cartId' => $this->input->post('cartId'),
                        'vcartId' => $this->input->post('vcartId'),
                        'terms' => $this->input->post('terms')
                    );
            // write to session
            $this->session->set_userdata($session);
            // redirect to page two
            redirect('shop/device/'.$this->dealer->dealer.'/plan_information', 'refresh');
        }
    }


Messages In This Thread
SOLVED - FORM VAL / SESSION, more than one error page two errors out?? - by El Forum - 05-01-2009, 02:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB