Welcome Guest, Not a member yet? Register   Sign In
Store multiple "identical" arrays in a session - confused about variable/dynamic variables
#1

[eluser]munkeh[/eluser]
I have a form that spans a few pages (well, technically it's a different form on each page but to the user it's a multi-stage form, I guess). The thing is, I need to grab all the data and do some validation before putting it all into the database at the end. Aha, you say - store it in a session! Well, I'm doing that but one of the forms is for the user to add information about a warranty part and there may be more than one part.

From browsing php.net I think I need to look into variable variables and while I understand the concept I can't wrap my head around it in practice.

Say I have a form that has a button "add part". I grab the POST data and build an array to store this in the session like so:
Code:
$add_parts = array(
                'form_description' => set_value('form_description'),
                'form_removed_part_number' => set_value('form_removed_part_number'),        
                'form_part_failure_date' => set_value('form_part_failure_date'),
                'form_work_order' => set_value('form_work_order')
            );
            
$this->session->set_userdata($add_parts);

The user is presented with a confirmation screen and has the opportunity to commit the data or add another part and it's this that I'm not clear on. I need to somehow figure out whether I've already added $add_parts to the session and, if so, increment some variable names and add it again while making note of the fact that there are multiple $add_parts arrays in the session.. I think?

I think I know what I need to do but I can't figure out how to do it! Help! Smile


Messages In This Thread
Store multiple "identical" arrays in a session - confused about variable/dynamic variables - by El Forum - 08-19-2010, 08:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB