I have a form.php that asks people how many registrations they want for each of 4 different conferences and saves the data in a session variable called
$_SESSION['formlist'] = $formlist;
That page is processed by formAction.php. formAction.php sends them to the first form they need with this code:
$indP = $_POST['ind'];
$famP = $_POST['fam'];
$saP = $_POST['sa'];
$sibP = $_POST['sib'];
$_SESSION['formlist'] = array('ind' => $indP, 'fam' => $famP, 'sa' => $saP, 'sib' => $sibP);
showForms($ind, $fam, $sa, $sib);
function showForms($ind, $fam, $sa, $sib) {
$ind = $_SESSION['formlist']['ind'];
$fam = $_SESSION['formlist']['fam'];
$sa = $_SESSION['formlist']['sa'];
$sib = $_SESSION['formlist']['sib'];
if($ind != "" and $ind != 0){
header("Location:formInd.php");
} else if($fam != "" and $fam != 0){
header("Location:formFam.php");
} else if($sa != "" and $sa != 0){
header("Location:formSA.php");
} else if($sib != "" and $sib != 0){
header("Location:formSib.php");
}
}
Say they want 2 ind forms, 1 fam form and 2 sib forms ($ind=2, $fam=1, $sib=2). They would be sent to formInd.php since they have at least 1 ind form. At formInd.php, I want them to be able to fill out the form on that page, then when they submit the data, formAction.php would decrease the number of ind forms they need by 1 and send them back to formInd.php. When they submit the second time, $ind would now be zero, so they should be automatically redirected to formFam since they have a family form to fill out.
The first part works -- they fill out form.php and based on their answers, it'll send them to the right page. However, once they're on one of the registration pages (e.g., formInd.php), I can't get it to read the session variable on formAction.php anymore. I haven't put in the decremement yet because right now, it's not even reading the session variable when it arrives back at formAction.php from formInd.php. Can anyone see what I'm missing?