Here it is:
<?php
if($_SERVER['REQUEST_METHOD ']=='POST'){
$Number=$_POST['Number'];
$Email=$_POST['Email'];
$Number2=0;
$error=0;
$Variable1=$_PO ST['Variable1'];
$Variable2=$_PO ST['Variable2'];
$Variable3=$_PO ST['Variable3'];
$Variable4=$_PO ST['SVariable4'];
$Variable5=$_PO ST['Variable5'];
$Variable6=$_PO ST['Variable6'];
$Variable7=$_PO ST['IVariable7'];
$Variable8=$_PO ST['Variable8'];
$Check=$_POST['Check']; //We will use this to
determine if we
should do data checks
if (empty($Variabl e1)){
$msg1=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e2)){
$msg2=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e3)){
$msg3=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e4)){
$msg4=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e5)){
$msg5=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e6)){
$msg6=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e7)){
$msg7=" * You have not answered this
question.";
$error++;
}
$Variable9=$_PO ST['Variable9'];
$Variable10=$_P OST['Variable10'];
$Variable11=$_P OST['Variable11'];
$Variable12=$_P OST['Variable12'];
$Variable13=$_P OST['Variable13'];
$Variable14=$_P OST['Variable14'];
$Variable15=$_P OST['Variable15'];
$Variable16=$_P OST['Variable16'];
$Variable17=$_P OST['Variable17'];
for ($i=0; $i<$Number; $i++){
if (empty($Variabl e9[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e10[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e11[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e12[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e13[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e14[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e15[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e16[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e17[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
} //closes FOR loop
if ($error>0){
echo "<form action=\"survey .php\" method=\"POST\" >
<input type=\"hidden\" name=\"Email\" value=\"$Email
\" />
<input name=\"Number\" type=\"hidden\" value=\" $Number
\" />
<table width=\"700\" border=\"0\" cellpadding=\"0 \"
align=\"center
\">
<tr><td colspan=\"25\"> <strong><center >PART 1 -
SURVEY</center></
strong<br/></td></tr>
<tr><td align=\"right\" ></tr>
<tr><td align=\"right\" ></td></tr>
<tr><td colspan=\"25\"> Please answser the following
questions:<br/
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">1. Question
1?</
td </tr>
<tr>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg1</td></tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">2.
Question 2?</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg2</td></tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">3.
Question 3?</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 3\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "<input name=\"Variable 3\"type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 3\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 3\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $Variety</td>
</tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">4.
Question 4?</td></
tr>
<tr>
<td align=\"center\ "><input name=\"Variable 4\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 4\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "<input name=\"Variable 4\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 4\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg4</td>
</tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">5.
Question 5?</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 5\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 5\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 5\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "<input name=\"Variable 5\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"$ msg5</td>
</tr>
<tr>
<td colspan=\"25\" bgcolor=\"#CCCC CC\">6. Question 6?
</td>
</tr>
<tr>
<td align=\"center\ "><input name=\"Variable 6\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "<input name=\"Variable 6\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 6\" type=
\"radio\" Value=
\"Average\"/Average</td>
<td align=\"center\ "><input name=\"Variable 6\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg6</td>
</tr>
<tr>
<td colspan=\"25\" bgcolor=\"#CCCC CC\">7. Question 7?
</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 7\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 7\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 7\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "<input name=\"Variable 7\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg7</td>
</tr>
</table>
<br/
COMMENTS: <br/><div align=\"center\ "><textarea name=\"Variable 8\"
cols=
\"83\" rows=\"10\"></textarea></div><div align=\"center\ "><br/>
<br/>
<strong>
<center>";
if ($Number>0){
echo "<table width=\"700\" border=\"0\"
cellpadding=\"5 \">
<tr><td colspan=
\"10\"><strong> <center>PART 2 - SURVEY
</center</strong></td></tr><tr><td colspan=\"10\"</td></tr>
<tr><td colspan=\"10\"> <div align=
\"center\">Plea se fill out
each section below. </div></td></tr></table><br/></center></strong>";
$SeminarNumber= 1;
while ($Number2<$Numb er){
echo "<table width=\"700\"
border=\"0\" cellpadding=\"0 \" align=
\"center\">
<tr><td colspan=\"60\" align=
\"center\"><str ong>Seminar
Number
$SeminarNumber</strong></td></tr>
<tr><td align=\"right
\">Variable9 : </td><td colspan=\"5\">< input
type=\"text\" name=\"Variable 9[]$Number2\" value=\"\" width=\"250\"/
$msg[$Number]</td></tr>
<tr><td colspan=\"60\"</td></
tr>
<tr><td colspan=\"60\" bgcolor=
\"#CCCCCC\"> 1. Question 10?</td></
tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 10]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ " ><input
name=\"Variable 10[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ " ><input
name=\"Variable 10[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ " ><input
name=\"Variable 10[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td>
</tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">2. Question 11?</td></
tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"$ msg[$Number]
</td>
</tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">3. Question 12?</td></
tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td></tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">4. Question 13
</td></tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td>
</tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\"5.Question 14? </
td></tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td></tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">6.Questio n 15?. </td>
</tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Average \"/>Average</td>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td></tr>
<tr><td colspan=\"60\"> <hr/></
td></tr>
</table><br/>";
$Number2++;
$SeminarNumber+ +;
} //Closes While Loop
echo "<table width=\"700\" border=\"0\" cellpadding=\"0 \" align=
\"center\">
<tr><td colspan=\"60\" bgcolor=\"#CCCC CC\">Question 16: </td>
</tr>
<tr><td colspan=\"60\" align=\"center\ "><div align=\"center
\"><textarea name=\"Variable 16[]\" cols=\"83\" rows=\"5\"></textarea>
</div></td></tr>
<tr><td<input type=\"hidden\" name=\"Check\" value=\"1\"</
td></tr>
<tr><td bgcolor=\"#CCCC CC\">ADDITIONA L COMMENTS: </td></tr>
<tr><td><div align=\"center\ "><textarea name=\"Variable 17[]\"
cols=
\"83\" rows=\"10\"></textarea></div><br/></td></tr>
</table>
<div align=\"center\ "><br/>If you are interested in receiving
information or materials, please email me at <a href=
\"mailto:e...@e mail.com\">e... @email.com</a>.</div>
<div align=\"center\ "><br/><input name=\"Submit\" type=\"Submit
\"
value=\"Submit\ ">
<input name=\"Reset\" type=
\"Reset\" value=\"Reset\" ></div>
</form>";
} //closes the IF ($Number2>0) loop
for if the user entered a
number for seminars
} //closes the IF ($error>0) loop
else{
include('submit .php');
}
} //closes the check POST validation IF
else{
echo"You can not access this page directly. To complete the
survey,
go to
<br/><a href =\"http://www.website.com/index.php\">Sur vey
Form</a>";
}
?>
I tried formatting it for easy viewing, don't know if I succeeded. A
brief explanation is in order. The first page of the form asks a user
for a number and their email address. The number and email address are
passed to the second page of the form, which is the script listed
above. First thing we do is declare local variables. Next, we check
for any empty variables. If there are, $error>0 and we display the
form. If $error<=0, we call the submit.php page which writes
everything to the database.
The FOR loop in the middle determines if a customer entered a number
on the previous page. If there is a number, then it executes the next
block of code. If not, we skip this section. This way, if the customer
enters 0 or nothing for the number on the first page, then we don't
clutter up the screen with those questions. The WHILE loop right below
there, repeats certain questions for the number of times the user
entered on the first page. So there is a set of questions that is
asked once of all users, and a set of questions that is asked a number
of times, depending on what number the customer entered. The form
repeats the questions the correct number of times.
I am trying to accomplish some form of data verification. For the
first set of question, data verification works correctly, by not
allowing you to move further until every question is answered.
However, it automatically displays the error messages when the page
loads. I can't use an inline if($_SERVER['REQUEST_METHOD ']=='POST')
{ echo $msg[i]; } method, since the form is always posted. Inside of
the WHILE loop, I can only get it to verify $Variable9. It doesn't
even check the other fields . Since the same question may be asked 10
times, I need to specify which occurrence of the question was not
answered. That is why I use the FOR loop.
If you know of a way to make the current code work, or if you have a
better idea of how to do this from top to bottom, please let me know.
I would like to also be able to carry over the user's selections, so
that they don't have to recheck each box, if they only left off one.
<?php
if($_SERVER['REQUEST_METHOD ']=='POST'){
$Number=$_POST['Number'];
$Email=$_POST['Email'];
$Number2=0;
$error=0;
$Variable1=$_PO ST['Variable1'];
$Variable2=$_PO ST['Variable2'];
$Variable3=$_PO ST['Variable3'];
$Variable4=$_PO ST['SVariable4'];
$Variable5=$_PO ST['Variable5'];
$Variable6=$_PO ST['Variable6'];
$Variable7=$_PO ST['IVariable7'];
$Variable8=$_PO ST['Variable8'];
$Check=$_POST['Check']; //We will use this to
determine if we
should do data checks
if (empty($Variabl e1)){
$msg1=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e2)){
$msg2=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e3)){
$msg3=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e4)){
$msg4=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e5)){
$msg5=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e6)){
$msg6=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e7)){
$msg7=" * You have not answered this
question.";
$error++;
}
$Variable9=$_PO ST['Variable9'];
$Variable10=$_P OST['Variable10'];
$Variable11=$_P OST['Variable11'];
$Variable12=$_P OST['Variable12'];
$Variable13=$_P OST['Variable13'];
$Variable14=$_P OST['Variable14'];
$Variable15=$_P OST['Variable15'];
$Variable16=$_P OST['Variable16'];
$Variable17=$_P OST['Variable17'];
for ($i=0; $i<$Number; $i++){
if (empty($Variabl e9[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e10[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e11[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e12[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e13[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e14[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e15[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e16[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
if (empty($Variabl e17[$i])){
$msg[i]=" * You have not answered this
question.";
$error++;
}
} //closes FOR loop
if ($error>0){
echo "<form action=\"survey .php\" method=\"POST\" >
<input type=\"hidden\" name=\"Email\" value=\"$Email
\" />
<input name=\"Number\" type=\"hidden\" value=\" $Number
\" />
<table width=\"700\" border=\"0\" cellpadding=\"0 \"
align=\"center
\">
<tr><td colspan=\"25\"> <strong><center >PART 1 -
SURVEY</center></
strong<br/></td></tr>
<tr><td align=\"right\" ></tr>
<tr><td align=\"right\" ></td></tr>
<tr><td colspan=\"25\"> Please answser the following
questions:<br/
><br/></td </tr>
1?</
td </tr>
<tr>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 1\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg1</td></tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">2.
Question 2?</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 2\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg2</td></tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">3.
Question 3?</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 3\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "<input name=\"Variable 3\"type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 3\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 3\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $Variety</td>
</tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">4.
Question 4?</td></
tr>
<tr>
<td align=\"center\ "><input name=\"Variable 4\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 4\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "<input name=\"Variable 4\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "><input name=\"Variable 4\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg4</td>
</tr>
<tr><td colspan=\"25\" bgcolor=\"#CCCC CC\">5.
Question 5?</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 5\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 5\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 5\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "<input name=\"Variable 5\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"$ msg5</td>
</tr>
<tr>
<td colspan=\"25\" bgcolor=\"#CCCC CC\">6. Question 6?
</td>
</tr>
<tr>
<td align=\"center\ "><input name=\"Variable 6\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "<input name=\"Variable 6\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 6\" type=
\"radio\" Value=
\"Average\"/Average</td>
<td align=\"center\ "><input name=\"Variable 6\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg6</td>
</tr>
<tr>
<td colspan=\"25\" bgcolor=\"#CCCC CC\">7. Question 7?
</td></tr>
<tr>
<td align=\"center\ "><input name=\"Variable 7\" type=
\"radio\" value=
\"Excellent\ " /Excellent</td>
<td align=\"center\ "><input name=\"Variable 7\" type=
\"radio\" value=
\"Good\" /Good</td>
<td align=\"center\ "><input name=\"Variable 7\" type=
\"radio\" value=
\"Average\" /Average</td>
<td align=\"center\ "<input name=\"Variable 7\" type=
\"radio\" value=
\"Poor\" /Poor</td>
<td colspan=\"21\"> $msg7</td>
</tr>
</table>
<br/
ADDITIONAL
cols=
\"83\" rows=\"10\"></textarea></div><div align=\"center\ "><br/>
<br/>
<strong>
<center>";
if ($Number>0){
echo "<table width=\"700\" border=\"0\"
cellpadding=\"5 \">
<tr><td colspan=
\"10\"><strong> <center>PART 2 - SURVEY
</center</strong></td></tr><tr><td colspan=\"10\"</td></tr>
<tr><td colspan=\"10\"> <div align=
\"center\">Plea se fill out
each section below. </div></td></tr></table><br/></center></strong>";
$SeminarNumber= 1;
while ($Number2<$Numb er){
echo "<table width=\"700\"
border=\"0\" cellpadding=\"0 \" align=
\"center\">
<tr><td colspan=\"60\" align=
\"center\"><str ong>Seminar
Number
$SeminarNumber</strong></td></tr>
<tr><td align=\"right
\">Variable9 : </td><td colspan=\"5\">< input
type=\"text\" name=\"Variable 9[]$Number2\" value=\"\" width=\"250\"/
></td></td><td colspan=\"21\">
<tr><td colspan=\"60\"</td></
tr>
<tr><td colspan=\"60\" bgcolor=
\"#CCCCCC\"> 1. Question 10?</td></
tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 10]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ " ><input
name=\"Variable 10[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ " ><input
name=\"Variable 10[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ " ><input
name=\"Variable 10[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td>
</tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">2. Question 11?</td></
tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 11[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"$ msg[$Number]
</td>
</tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">3. Question 12?</td></
tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 12[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td></tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">4. Question 13
</td></tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 13[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td>
</tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\"5.Question 14? </
td></tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Average \" />Average</td>
<td align=\"center\ "><input
name=\"Variable 14[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td></tr>
<tr><td colspan=\"60\"
bgcolor=\"#CCCC CC\">6.Questio n 15?. </td>
</tr>
<tr>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Excelle nt\" />Excellent</td>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Good\" />Good</td>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Average \"/>Average</td>
<td align=\"center\ "><input
name=\"Variable 15[]$Number2\" type=
\"radio\" value=\"Poor\" />Poor</td><td colspan=\"21\"> $msg[$Number]</
td></tr>
<tr><td colspan=\"60\"> <hr/></
td></tr>
</table><br/>";
$Number2++;
$SeminarNumber+ +;
} //Closes While Loop
echo "<table width=\"700\" border=\"0\" cellpadding=\"0 \" align=
\"center\">
<tr><td colspan=\"60\" bgcolor=\"#CCCC CC\">Question 16: </td>
</tr>
<tr><td colspan=\"60\" align=\"center\ "><div align=\"center
\"><textarea name=\"Variable 16[]\" cols=\"83\" rows=\"5\"></textarea>
</div></td></tr>
<tr><td<input type=\"hidden\" name=\"Check\" value=\"1\"</
td></tr>
<tr><td bgcolor=\"#CCCC CC\">ADDITIONA L COMMENTS: </td></tr>
<tr><td><div align=\"center\ "><textarea name=\"Variable 17[]\"
cols=
\"83\" rows=\"10\"></textarea></div><br/></td></tr>
</table>
<div align=\"center\ "><br/>If you are interested in receiving
information or materials, please email me at <a href=
\"mailto:e...@e mail.com\">e... @email.com</a>.</div>
<div align=\"center\ "><br/><input name=\"Submit\" type=\"Submit
\"
value=\"Submit\ ">
<input name=\"Reset\" type=
\"Reset\" value=\"Reset\" ></div>
</form>";
} //closes the IF ($Number2>0) loop
for if the user entered a
number for seminars
} //closes the IF ($error>0) loop
else{
include('submit .php');
}
} //closes the check POST validation IF
else{
echo"You can not access this page directly. To complete the
survey,
go to
<br/><a href =\"http://www.website.com/index.php\">Sur vey
Form</a>";
}
?>
I tried formatting it for easy viewing, don't know if I succeeded. A
brief explanation is in order. The first page of the form asks a user
for a number and their email address. The number and email address are
passed to the second page of the form, which is the script listed
above. First thing we do is declare local variables. Next, we check
for any empty variables. If there are, $error>0 and we display the
form. If $error<=0, we call the submit.php page which writes
everything to the database.
The FOR loop in the middle determines if a customer entered a number
on the previous page. If there is a number, then it executes the next
block of code. If not, we skip this section. This way, if the customer
enters 0 or nothing for the number on the first page, then we don't
clutter up the screen with those questions. The WHILE loop right below
there, repeats certain questions for the number of times the user
entered on the first page. So there is a set of questions that is
asked once of all users, and a set of questions that is asked a number
of times, depending on what number the customer entered. The form
repeats the questions the correct number of times.
I am trying to accomplish some form of data verification. For the
first set of question, data verification works correctly, by not
allowing you to move further until every question is answered.
However, it automatically displays the error messages when the page
loads. I can't use an inline if($_SERVER['REQUEST_METHOD ']=='POST')
{ echo $msg[i]; } method, since the form is always posted. Inside of
the WHILE loop, I can only get it to verify $Variable9. It doesn't
even check the other fields . Since the same question may be asked 10
times, I need to specify which occurrence of the question was not
answered. That is why I use the FOR loop.
If you know of a way to make the current code work, or if you have a
better idea of how to do this from top to bottom, please let me know.
I would like to also be able to carry over the user's selections, so
that they don't have to recheck each box, if they only left off one.
Comment