Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
storing session data and using at a later stage
Old 11-11-2005, 08:22 AM storing session data and using at a later stage
Junior Talker

Posts: 1
Trades: 0
Hi there,
I am building an online insurance booking form which over several screens will take details of people to be insured.

On the first screen, the client specifies the amount of people he wants to insure. On the second screen I have used a loop to create the correct amount of spaces to take the details of each person he wants to insure.

Now where i'm getting stuck (and this is probably something strait forward) is how I store each of these person's details in the session and then recall them a couple of screens later to firstly confirm the client's details but then also to save onto the server for the insurance to be issued.

Information such as telephone number and address for example is easy because I know that there will only be one variable name to store in the session, but with the list of client's details I am not going to know how many there as that is controlled by the person entering in the amount on the front page.

I have got as far as creating a loop which as well as creating the correct amount of spaces for the details but it also names each text box a unique name i.e. name1, age1, name2, age2, name3, age3 etc.
Do I add something to the loop which will add each of the details to a session variable eerytime it loops?

Any help or suggestions would be really appreciated.

Many thanks

will
will83 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-11-2005, 01:02 PM
Junior Talker

Posts: 4
Location: NJ
Trades: 0
nevermind... didn't read your post right

Last edited by impressM_Hector; 11-11-2005 at 01:08 PM.. Reason: wrong answer... sorry
impressM_Hector is offline
Reply With Quote
View Public Profile Visit impressM_Hector's homepage!
 
Old 11-11-2005, 05:16 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You can build forms that store arrays of variables. Give all the related fields the same name, but put brackets on the end:
<input type="text" name="age[]" />

Then in PHP when you process the form (if page 2 submits to page 3, then before you display the form on page 3 you can grab the data from page 2 and stick it into $_SESSION), the $_POST array will have an item in it called $_POST['age'], which will be another array containing all the fields called age in the order they appeared on the page.
If you want more control over where the field appear in the array you can call them age[1] age[2] age[34] age[0] age[8] in that order should you want to and they will come out at those positions in the array. To et this data into $_SESSION you can just copy the whole thing over and reference it later,

$_SESSION['age_array'] = $_POST['age'];

Is all it should require.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 12-21-2005, 10:00 AM cheers
Novice Talker

Posts: 12
Trades: 0
keep it simple... ensure that your form field name contain no spaces and have human-readable names, then use the following code to Keep It Simple:

foreach ($_REQUEST as $varname) {
$_SESSION[$varname] = $_REQUEST[$varname];
}
synapsex is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to storing session data and using at a later stage
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20576 seconds with 12 queries