Welcome Guest, Not a member yet? Register   Sign In
Problem in form submission
#1

[eluser]smithas[/eluser]
I have a form which has two pages.After completion of second page only i can add data to database.How can i make the submittted data from first page available in second page? i load the second page from a function in the same controller.
here is the code
Code:
<?php
class Update_profile_shopper extends Controller
{
    function Update_profile_shopper()
    {
        parent::Controller();
        $this->load->helper('form','url');
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters
        ('<label class="star">', '</label>');
        
    }
    
    function index()
    {

        
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('update_profile_shopper_view');
        }
        else
        {
            

               $this->update_shopper_pref();
            
        }
    }
    
    
    function update_shopper_pref()
    {
        
        
        if($this->form_validation->run()== FALSE)
        {
            
            $this->load->view('update_shopper_pref_view');
        }
        else
        {
            
            echo "saved";
            
        }
        
    }

    
}

what should i put in the else part of update_shopper_pref() function?i tried using global variables for passing values..but somehow that is also not working.Pls help.
#2

[eluser]InsiteFX[/eluser]
Look in the user guide on flash data should work for you.

Enjoy
InsiteFX
#3

[eluser]bigtony[/eluser]
[quote author="InsiteFX" date="1249047795"]Look in the user guide on flash data should work for you.[/quote]
Agree, although I would be tempted rather to use permanent session variables as there's less chance of losing the data if, say, a validation error reload clears it. Also, if later on make into 3 pages rather than 2 then you know all the data will still be there.
#4

[eluser]smithas[/eluser]
i have a large number of fields in first page.
so i gathered all of them in an array $params
and then $this->session->set_flashdata($params);

but in the next page i need to use keep_flashdata() function.
How can we use keep_flashdata() function when passing an array?
#5

[eluser]bigtony[/eluser]
[quote author="smithas" date="1249052861"]i have a large number of fields in first page.
so i gathered all of them in an array $params
and then $this->session->set_flashdata($params);

but in the next page i need to use keep_flashdata() function.
How can we use keep_flashdata() function when passing an array?[/quote]
Again, I recommend using set_userdata rather than flashdata, as then it's 'kept' for you. Just retrieve with $this->session->userdata('array_name');

If you want, you can unset_userdata when all finished.
#6

[eluser]smithas[/eluser]
ok.maybe i vl try that.thanks Smile




Theme © iAndrew 2016 - Forum software by © MyBB