Believe it or not, I've spent about 4 more hours trying to figure this out, and I still don't have it. I think the problem is that I'm setting some variables in a conditional that no longer exists when I need to use the variables again.
I wrote out in peudo code the spot where the problem seems to be:
[INDENT]IF (POST indfam is set) {
echo the list of links;
(This is where the variables exist that I need to pass to the GET code block below. I made them into SESSION variables, btw.)
}
IF (GET func is set (i.e., a link is clicked)) {
call the appropriate function that echoes the correct form;
(I need the variables to still exist here.)
}[/INDENT]
If I change the POST conditional to IF (3 == 3), everything else works, so somehow, the POST conditional info (the part in red above) is getting wiped out when the links are clicked.
Can someone help? I feel like I've isolated the problem, but I still can't figure out how to solve it.
If you want to see the actual code, I'll put it below. The part I pseudo-coded above is about half way through -- it's commented as "Creating the links . . . ":
<?php
session_start();
ob_start();
require_once("templates/formStrings2006.php");
head("NDSC 2006 Convention");
$thisFile = $_SERVER['PHP_SELF'];
///////////// BEGIN setting variables ////////////////////
if ($_POST['submit']) {
$indFam = $_POST['indFam'];
$saP = $_POST['sa'];
$sibP = $_POST['sib'];
if ($_POST['indFam'] == "ind"){
$ind = 1;
}else{
$ind = 0;
}
if ($_POST['indFam'] == "fam"){
$fam = 1;
}else{
$fam = 0;
}
$_SESSION['formlist'] = array('indFam' => $_POST['indFam'], 'sa' => $_POST['sa'], 'sib' => $_POST['sib']);
$indFam = $_SESSION['formlist']['indFam'];
$sa = $_SESSION['formlist']['sa'];
$sib = $_SESSION['formlist']['sib'];
}
/////////// Functions that call each form ///////////////////////
function indForm($indForm) {
echo $indForm;
}
function famForm($famForm) {
echo $famForm;
}
function saForm($saForm) {
echo $saForm;
}
function sibForm($sibForm) {
echo $sibForm;
}
/////// Creating the Links - The problem in the if (isset($_POST['indFam'])) part /////////
if (!isset($_POST['indFam']) && !isset($_GET['func'])) {
echo $gatherData;
} else if (isset($_POST['indFam'])) {
echo "<p>You selected: </p>";
if ($_POST['indFam'] == "ind") {
$indString = "<br><a href=\"?func=indForm\">Individual Form</a><br>";
echo $indString;
} else if ($_POST['indFam'] == "fam") {
$famString = "<br><a href=\"?func=famForm\">Family Form</a><br>";
echo $famString;
} // End if ($_POST['indFam'] == "ind")
if($sa != "" and $sa != 0){
for ($i = 1; $i <= $sa; $i++) {
$saString = "<br><a href=\"?func=saForm\">Self-Advocate Form #" . $i . "</a> ";
echo $saString;
}
echo "<br>";
}
if($sib != "" and $sib != 0){
for ($i = 1; $i <= $sib; $i++) {
$sibString = "<br><a href=\"?func=sibForm\">Brother and Sister Form #" . $i . "</a> ";
echo $sibString;
}
} // End if($sib != "" and $sib != 0)
} // End else if (isset($_POST['indFam']))
if (isset($_GET['func'])) {
if ($_GET['func'] == "indForm") {
indForm($indForm);
} else if ($_GET['func'] == "famForm") {
famForm($famForm);
}
if ($_GET['func'] == "saForm") {
saForm($saForm);
}
if ($_GET['func'] == "sibForm") {
sibForm($sibForm);
}
} // End if (!isset($_POST['indFam']) && !isset($_GET['func'])) {
?>