using session to store data and use at a later stage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Jenk, that was only to get him to understand what he was doing wrong there... :P Although I know other shortcuts too 8)
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

Ok my project simplified is:


Page 1:

Code: Select all

<form name="form1" action="step2.php" method="post">
<input size="3" maxlength="1" name="adults" id="adults" />
<input size="3" maxlength="1" name="children" id="children" />
<input type="submit" value="calculate" />
</form>

Page 2:

Code: Select all

<?php
session_start(); //Start Session
header("Cache-control: private"); //ie6 fix

$adults=$_POST['adults'];
$children=$_POST['children'];
$premium = bcmul(157,$adults,2) + bcmul(79,$children,2);
echo "$premium";
?>


Page 3:

Code: Select all

<?php
$adults=$_SESSION['adults'];
$children=$_SESSION['children'];

$aps = $adults + $children;

$i = 0;
while ($i<$aps) {
$i++;

print "<tr><td>\n";
print "<input name=\"initial"."$i"."\" />\n";
print "<input name=\"surname"."$i"."\" />\n";
print "</td></tr>\n";

}
?>
So that creates the correct amount of rows according the size of the group requiring insurance.



Page: 4

Just some more text boxes taking address and other details.



Page: 5

Page which displays the details so far.

With regards to displaying the Initials and Surname collected on Page 3:

Code: Select all

<?php

$_SESSION['initial ?    //here... Someway of recalling the stored variables from the session data.


//here....For loop reeling off the stored variables.

?>


Can anyone suggest something to use on my 5th page?

Thanks

Will
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

Ok I should have shown you this before:

This is what i'm trying to re-create. You see after the details are taken, it shows you the lilst of names to be insured.

http://www.healthcareinternational.com/ ... lIndex.htm

Will
Post Reply