Hi,
Basically, I have a variable called $sa that I need to be able to use in the code below that's not currently available. The $sa is a number that's generated by user input in a form -- it tells how many saForms they need. I'd like to be able to pass that number as a parameter to saForm. saForm outputs a certain kind of form and I'd like to be able to say at the top, "This is form #1 of 4". I can't figure out why it's not getting to this portion of the code:
if (isset($_GET['func'])) {
if ($_GET['func'] == "indForm") {
indForm($indForm);
} else if ($_GET['func'] == "famForm") {
famForm($famForm);
}
if ($_GET['func'] == "saForm, $sa") {
saForm($saForm);
}
if ($_GET['func'] == "sibForm") {
sibForm($sibForm);
}
}
Here's the whole script -- I kept the form strings in in case you needed them, but you can probably skip through all of that part of the code. I've got some echos for $sa at various places that are commented as to whether you can access the variable at that point:
<?php
session_start();
ob_start();
// Include database connections and templates
require_once("templates/t_convention2006.php");
require_once("classes/conferenceConfig.php");
require_once("classes/MySQL.php");
require_once("classes/Session.php");
head("NDSC 2006 Convention");
$thisFile = $_SERVER['PHP_SELF'];
//////////////////// The form strings ///////////////////////////////////
// Gathering the data for the array of forms
$gatherData = <<< GATHERDATA
<p>Please tell us how many of each type of registration that you need:</p>
<!-- Form begins here -->
<form action="$thisFile" method="post" name="gatherdata" enctype="multipart/form-data" >
<!-- <p><input type="textbox" size="1" name="ind" id="ind"> Individual Registration</p>
<p><input type="textbox" size="1" name="fam" id="fam"> Family Registration</p> -->
<select name="indFam"> (does not include Youth/Adult Registration or Brother/Sister Registration)
<option value="">Choose One
<option value="ind" id="ind">Individual
<option value="fam" id="fam">Family
</select><br><br>
<p><input type="textbox" size="1" name="sa" id="sa"> Self-Advocate Registration</p>
<p><input type="textbox" size="1" name="sib" id="sib"> Brother/Sister Registration</p>
<p><input type="submit" name="submit" id="submit" value="Gather the Forms"></p>
</form>
<!-- Form ends here -->
GATHERDATA;
///// Individual Form
$indForm = <<< INDFORM
<!-- Form begins here -->
<p>Individual Form</p>
<form action="$thisFile" method="post" name="indform" enctype="multipart/form-data" >
* NDSC Member? <select name="Membership Status">
<option value="">
<option value="Yes">Yes
<option value="No">No
</select><br><br>
Your Name (First) <input type="text" name="firstName" id="firstName" size="47"><br><br>
Your Name (Last) <input type="text" name="lastName" id="lastName" size="47"><br><br>
<p><input type="submit" name="submit" id="submit" value="Add This Registrant"></p>
</form>
<!-- Form ends here -->
INDFORM;
///// Family Form
$famForm = <<< FAMFORM
<!-- Form begins here -->
<p>Family Form</p>
<form action="$thisFile" method="post" name="famform" enctype="multipart/form-data" >
* NDSC Member? <select name="Membership Status">
<option value="">
<option value="Yes">Yes
<option value="No">No
</select><br><br>
Your Name (First) <input type="text" name="firstName" id="firstName" size="47"><br><br>
Your Name (Last) <input type="text" name="lastName" id="lastName" size="47"><br><br>
<p><input type="submit" name="submit" id="submit" value="Add This Registrant"></p>
</form>
<!-- Form ends here -->
FAMFORM;
///// Self-Advocate Form
$saForm = <<< SAFORM
<!-- Form begins here -->
<p>Self-Advocate Form</p>
<form action="$thisFile" method="post" name="saform" enctype="multipart/form-data" >
* NDSC Member? <select name="Membership Status">
<option value="">
<option value="Yes">Yes
<option value="No">No
</select><br><br>
Your Name (First) <input type="text" name="firstName" id="firstName" size="47"><br><br>
Your Name (Last) <input type="text" name="lastName" id="lastName" size="47"><br><br>
<p><input type="submit" name="submit" id="submit" value="Add This Registrant"></p>
</form>
<!-- Form ends here -->
SAFORM;
///// Brother/Sister Form
$sibForm = <<< SIBFORM
<!-- Form begins here -->
<p>Brother and Sister Form</p>
<form action="$thisFile" method="post" name="sibform" enctype="multipart/form-data" >
* NDSC Member? <select name="Membership Status">
<option value="">
<option value="Yes">Yes
<option value="No">No
</select><br><br>
Your Name (First) <input type="text" name="firstName" id="firstName" size="47"><br><br>
Your Name (Last) <input type="text" name="lastName" id="lastName" size="47"><br><br>
<p><input type="submit" name="submit" id="submit" value="Add This Registrant"></p>
</form>
<!-- Form ends here -->
SIBFORM;
////////////// END form strings; 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'];
}
////////////////////// Creating the Links //////////////////
function indForm($indForm) {
echo $indForm;
}
function famForm($famForm) {
echo $famForm;
}
function saForm($saForm, $sa) {
echo "<br>sa var from saForm():" . $sa; /// This one does not work.
echo $saForm;
}
function sibForm($sibForm) {
echo $sibForm;
}
if (!isset($_POST['indFam']) && !isset($_GET['func'])) {
echo $gatherData;
} else if (isset($_POST['indFam'])) {
$linkString = "";
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'])) {
echo "<br>sa before isset:" . $sa; /// This one DOES work until you click on a link.
if (isset($_GET['func'])) {
echo "<br>sa var from right inside if isset GET:" . $GLOBALS['$sa']; /// This one does not work.
if ($_GET['func'] == "indForm") {
indForm($indForm);
} else if ($_GET['func'] == "famForm") {
famForm($famForm);
}
if ($_GET['func'] == "saForm") {
echo "<br>sa var from GET:" . $sa;
saForm($saForm, $sa);
}
if ($_GET['func'] == "sibForm") {
sibForm($sibForm);
}
} // End if (!isset($_POST['indFam']) && !isset($_GET['func'])) {
///////////////// End Creating the Links ///////////////////////////////
foot();
?>