HI Folks.
I am working on a project which involves creating a multipage form, using a single php script and without javascript.
So, far I have the page breaks working fine, but the issue is the placement of the hidden variables.
I have tried numerous places to carry the values over to the last page.
So, my issues that I ask for help with are:
1. Passing the values of each input, back and forth through the form. So it the user hits the back button, the values are kept.
2. Actually getting a back button to use, rather than the browser back button.
3. For now, getting the values of each variable to echo on the last page of the form.
The final goal is to have the values emailed to a recipient, in the form of:
V1=Today
V2=1
etc..
Here is what I have so far, I have removed the hidden fields that I tried, for the sake of my sanity...🙂
<?php
$V1 = $_POST['V1'];
$V2 = $_POST['V2'];
$V3 = $_POST['V3'];
$V4 = $_POST['V4'];
$V5 = $_POST['V5'];
$page = $_GET['page'];
$pagenum = '3';
$QuestStr = '';
$title="<TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD> </TD></TR></TABLE><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD WIDTH=\"100%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"6\" COLOR=\"#000080\" FACE=\"Arial\"><B>Customer Survey 2001</B></FONT></TD></TR></TABLE>";
if($page=='')
{
$page='1';
}
if($page=='1')
{
$Q1="<TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD COLSPAN=\"5\"> </TD></TR></TABLE><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD WIDTH=\"10%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><a name=\"Q1\"><FONT SIZE=\"4\" COLOR=\"#000080\" FACE=\"Arial\"><B>1).</B></FONT></a></TD><TD WIDTH=\"40%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><B>When did you last visit the Metropole Restaurant?</B></FONT></TD><TD WIDTH=\"5%\"> </TD><TD WIDTH=\"45%\" ALIGN=\"LEFT\" VALIGN=\"BOTTOM\"><input type=text size=\"20\" maxlength=\"20\" name=\"V1\"></TD></TR></TABLE>";
{ $QuesStr=$Q1; }
}
if($page=='2')
{
$Q2GRID="<TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD COLSPAN=\"4\"> </TD></TR></TABLE><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD ROWSPAN=\"2\" WIDTH=\"10%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"4\" COLOR=\"#000080\" FACE=\"Arial\"><B>2).</B></FONT></a></TD><TD COLSPAN=\"3\" WIDTH=\"90%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><B>How many people were in your party on your last visit?</B></FONT></TD></TR><TR></TR>";
$Q2="<TR><TD ALIGN=\"LEFT\" VALIGN=\"TOP\"> </TD><TD WIDTH=\"25%\" ALIGN=\"LEFT\" VALIGN=\"BOTTOM\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><I>Adults</I></FONT></TD><TD WIDTH=\"65%\" ALIGN=\"LEFT\" VALIGN=\"BOTTOM\"><input type=text size=\"2\" maxlength=\"2\" name=\"V2\"></TD></TR>";
$Q3="<TR><TD WIDTH=\"10%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"4\" COLOR=\"#000080\" FACE=\"Arial\"><B> </B></FONT></a></TD><TD WIDTH=\"25%\" ALIGN=\"LEFT\" VALIGN=\"BOTTOM\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><I>Children</I></FONT></TD><TD WIDTH=\"65%\" ALIGN=\"LEFT\" VALIGN=\"BOTTOM\"><input type=text size=\"2\" maxlength=\"2\" name=\"V3\"></TD></TR>";
$Q2EGRID="</TABLE>";
{ $QuesStr=$Q2GRID.$Q2.$Q3.$Q2EGRID; }
}
if($page=='3')
{
$Q4="<TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD COLSPAN=\"5\"> </TD></TR></TABLE><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD ROWSPAN=\"5\" WIDTH=\"10%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><a name=\"Q9\"><FONT SIZE=\"4\" COLOR=\"#000080\" FACE=\"Arial\"><B>3).</B></FONT></a></TD><TD COLSPAN=\"4\" WIDTH=\"90%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><B>How old are you?</B></FONT></TD></TR><TR><TD ROWSPAN=\"4\" WIDTH=\"9%\"> </TD><TD WIDTH=\"81%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><I><select name=\"V4\"><option value=\"\">--Click Here--<option value=\"1\">Under 18<option value=\"2\">18-21<option value=\"3\">22-25<option value=\"4\">26-30<option value=\"5\">31-40<option value=\"6\">41-50<option value=\"7\">51-60<option value=\"8\">over 60</Select></I></FONT></TD></TR></TABLE>";
$Q5="<TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD COLSPAN=\"4\"> </TD></TR></TABLE><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Question\" WIDTH=\"100%\"><TR><TD ROWSPAN=\"3\" WIDTH=\"10%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><a name=\"Q10\"><FONT SIZE=\"4\" COLOR=\"#000080\" FACE=\"Arial\"><B>4).</B></FONT></a></TD><TD COLSPAN=\"3\" WIDTH=\"90%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><B>Are you male or female?</B></FONT></TD></TR><TR><TD ROWSPAN=\"2\" WIDTH=\"9%\"> </TD><TD WIDTH=\"81%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Code\" WIDTH=\"100%\"><TR><TD WIDTH=\"6%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><input type=radio value=\"1\" name=\"V5\"></TD><TD WIDTH=\"94%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><I>Male</I></FONT></TD></TR></TABLE></TD></TR><TR><TD WIDTH=\"81%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><TABLE BORDER=\"0\" CELLSPACING=\"0\" SUMMARY=\"Code\" WIDTH=\"100%\"><TR><TD WIDTH=\"6%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><input type=radio value=\"2\" name=\"V5\"></TD><TD WIDTH=\"94%\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"2\" COLOR=\"#000080\" FACE=\"Arial\"><I>Female</I></FONT></TD></TR></TABLE></TD></TR></TABLE>";
{ $QuesStr=$Q4.$Q5; }
}
if($page<$pagenum)
{
?>
<FORM METHOD='POST' ACTION="<?php $_SERVER['PHP_SELF']?>?page=<?php echo ($page+1) ?>">
<?php
echo $title;
echo $QuesStr;
echo "<DIV><hr></DIV>";
echo "<input type='submit' value='Next'>";
echo "</form>";
}
else
{
?>
<FORM METHOD='POST' ACTION="<?php $_SERVER['PHP_SELF']?>?page=<?php echo ($page+1) ?>">
<?php
echo $title;
echo $QuesStr;
echo "<DIV><hr></DIV>";
echo "<input type='submit' value='Submit'>";
echo "</form>";
}
?>
Any help or advice would be greatly appreciated.
Thanks!!!
~Az