Forum Moderators: coopster

Message Too Old, No Replies

Multipage Form Help

         

german rookie

4:38 pm on Feb 5, 2006 (gmt 0)

10+ Year Member



Hy everybody sorry for my bad English,

I need help so mak e a Form like this

<?php

if (isset ($_GET["step"]))
$step = $_GET["step"];
else
$step = 1;


//los gehts
switch ($step){
case 1:

echo "<form name=\"form1\" method=\"post\" action =\"" . $sess->url("front_content.php?idcat=86&step=2") . "\" >
<div><input name=\"firstname\" type=\"text\"></div>
<div><input name=\"step2\" type=\"submit\" id=\"step2\" value=\"step 2\"></div></form>";
break;

case 2:
if (isset ($_POST["step2"]))
{
echo "<form name=\"form1\" method=\"post\" action =\"" . $sess->url("front_content.php?idcat=86&step=3") . "\" >
<div><input name=\"name\" type=\"text\"></div>
<div><input name=\"step3\" type=\"submit\" id=\"step3\" value=\"step 3\"></div></form>";
}
break;

case 3:
if (isset ($_POST["step3"]))
{
echo $firstname $name ;
}
break;




} //Ende switch

?>

It should be a multipage From that was include in a cms as a module. I didnot want to transportation the values by hiddenfields i think the better way is with Session but i didnt know how. I must say a Session already Starts at the head of this Form. Can you help me please or show me a good example that i can see how it works

greets from Germany

german rookie

12:35 am on Feb 6, 2006 (gmt 0)

10+ Year Member



No one any Idea?

coopster

8:37 pm on Feb 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, german rookie.

You can carry variables from form to form a number of ways. Yes, hidden form fields are one way, cookies are another, the query string is yet another, and of course then there are sessions. Here is a quick example of a session I found [webmasterworld.com], does that give you an idea of how it works?

german rookie

9:41 pm on Feb 6, 2006 (gmt 0)

10+ Year Member



Thanks coopster

I get now the methode of hiddenfields with an foreach

looks like


<?php

if (isset ($_GET["step"]))
$step = $_GET["step"];
else
$step = 1;

//los gehts
switch ($step){
case 1:

echo "<form name=\"form1\" method=\"post\" action =\"" . $sess->url("front_content.php?idcat=86&step=2") . "\" >
<table border=\"0\">";
$yes = "Yes";
$no = "No";
$section1 = "<h2>CMS_TEXT_SUB[12001]</h2>";
$form1 = "CMS_TEXT[50]"; //Name of the University
$form2 = "CMS_TEXT[51]"; //Faculty leader name
$form3 = "CMS_TEXT[52]"; //Mailing address
$form4 = "CMS_TEXT[53]"; //Title Position and Department
$form5 = "CMS_TEXT[54]"; //Office Phone
$form6 = "CMS_TEXT[55]"; //Fax
$form7 = "CMS_TEXT[56]"; //E-Mail
$form7a = "CMS_TEXT[560]"; //E-Mail Wiederholung
$form8 = "CMS_TEXT[57]"; //Have you led an international program before
$form9 = "CMS_TEXT[58]"; //Have you led a program to this proposed destination before
$form10 = "CMS_TEXT[59]"; //Have you led a program to this proposed destination before
$form11 = "CMS_TEXT[60]"; //Co-leader’s Name
$form12 = "CMS_TEXT[61]"; //Title/Position and Department
$form13 = "CMS_TEXT[62]"; //Office Phone
$form14 = "CMS_TEXT[63]"; //E-Mail
$section2 = "<h2>CMS_TEXT_SUB[12002]</h2>";
$form15 = "CMS_TEXT[64]"; //Program name / subject
$form16 = "CMS_TEXT[65]"; //Program Location(s)
$form17 = "CMS_TEXT[66]"; //What kind of program is planned
$form18 = "CMS_TEXT[67]"; //Duration: What is the minimum and maximum length of the program
$form19 = "CMS_TEXT[68]"; //Approximate program dates
$form20 = "CMS_TEXT[69]"; //What is the realistic minimum number of expected participating students
$form21 = "CMS_TEXT[70]"; //How many free places should be included in the program price
$form22 = "CMS_TEXT[71]"; //What is the budget per student
$form23 = "CMS_TEXT[72]"; //Are there any deadlines we should know about
echo "
<tr>
<td colspan=\"2\" style=\"border-bottom: 1px #000000 solid;\">$section1</td>
</tr>
<tr>
<td style=\"width:242px;\" class=\"fn_left\">$form1</td>
<td style=\"width:242px;\" class=\"fn_right\">$form2</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form1' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form2' type=\"text\"></td>
</tr>
<tr>
<td class=\"fn_left\">$form3</td>
<td class=\"fn_right\">$form4</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form3' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form4' type=\"text\"></td>
</tr>
<tr>
<td class=\"fn_left\">$form5</td>
<td class=\"fn_right\">$form6</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form5' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form6' type=\"text\"></td>
</tr>
<tr>
<td class=\"fn_left\">$form7</td>
<td class=\"fn_right\">$form7a</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form7' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form7a' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-top:10px;\">
<table>
<tr>
<td style=\"width:400px;text-align:left;padding-top:6px;\">$form8</td>
<td style=\"width:42px;text-align:right;\">$yes<input type=\"radio\" name='$form8' value='$yes' ></td>
<td style=\"width:42px;text-align:right;\">$no<input type=\"radio\" name='$form8' value='$no' ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan=\"2\">
<table>
<tr>
<td style=\"width:400px;text-align:left;padding-top:6px;\">$form9</td>
<td style=\"width:42px;text-align:right;\">$yes<input type=\"radio\" name='$form9' value='$yes' ></td>
<td style=\"width:42px;text-align:right;\">$no<input type=\"radio\" name='$form9' value='$no' ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-bottom:10px;\">
<table>
<tr>
<td style=\"width:400px;text-align:left;padding-top:6px;\">$form10</td>
<td style=\"width:42px;text-align:right;\">$yes<input type=\"radio\" name='$form10' value='$yes' ></td>
<td style=\"width:42px;text-align:right;\">$no<input type=\"radio\" name='$form10' value='$no' ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class=\"fn_left\">$form11</td>
<td class=\"fn_right\">$form12</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form11' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form12' type=\"text\"></td>
</tr>
<tr>
<td class=\"fn_left\">$form13</td>
<td class=\"fn_right\">$form14</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form13' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form14' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" style=\"border-bottom: 1px #000000 solid;padding-top:20px;\">$section2</td>
</tr>
<tr>
<td style=\"width:242px;\" class=\"fn_left\">$form15</td>
<td style=\"width:242px;\" class=\"fn_right\">$form16</td>
</tr>
<tr>
<td class=\"f_left\"><input class=\"formnorm\" name='$form15' type=\"text\"></td>
<td class=\"f_right\"><input class=\"formnorm\" name='$form16' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form17</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formlong\" name='$form17' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form18</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formnorm\" name='$form18' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form19</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formnorm\" name='$form19' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form20</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formnorm\" name='$form20' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form21</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formnorm\" name='$form21' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form22</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formnorm\" name='$form22' type=\"text\"></td>
</tr>
<tr>
<td colspan=\"2\" class=\"fn_long\">$form23</td>
</tr>
<tr>
<td colspan=\"2\" style=\"padding-left:4px;\"><input class=\"formlong\" name='$form23' type=\"text\"></td>
</tr>
</table>
<div>
<table border=\"0\" class=\"nexter\">
<tr>
<td style=\"width:200px;text-align:left;\"></td>
<td style=\"width:74px;text-align:center;\"><strong>Step 1 of 4</strong></td>
<td style=\"width:200px;text-align:right;\"><input name=\"step2\" class=\"formstepper\" type=\"submit\" id=\"step2\" value=\"next Step\"></td>
</tr>
</table></div> </form>";

break;

case 2:
if (isset ($_POST["step2"]))
{
echo "<form name=\"form1\" method=\"post\" action =\"" . $sess->url("front_content.php?idcat=86&step=3") . "\" >";
foreach($_POST as $key => $value) {echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";}
echo "<div><input name=\"Ort\" type=\"text\"></div>
<div><input name=\"step3\" type=\"submit\" id=\"step3\" value=\"Schritt 3\"></div> </form>";
}
break;

case 3:

if (isset ($_POST["step3"]))
{
echo "<form name=\"form3\" method=\"post\" action =\"" . $sess->url("front_content.php?idcat=86&step=4") . "\" >";
foreach($_POST as $key => $value) {echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";}
echo "<div>$Vorname $Name $Strasse $Ort</div>
<div><input name=\"step4\" type=\"submit\" id=\"step4\" value=\"Schritt 4\"></div></form>";
}
break;

case 4:

if (isset ($_POST["step3"]))
{
echo "<form name=\"form3\" method=\"post\" action =\"" . $sess->url("front_content.php?idcat=86&step=5") . "\" >";
foreach($_POST as $key => $value) {echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";}
echo "<div>$Vorname $Name $Strasse $Ort</div>
<div><input name=\"step4\" type=\"submit\" id=\"step4\" value=\"Schritt 5\"></div></form>";
}
break;




} //Ende switch

?>

the CMS_TEXT[50] is a textmodul in the CMS

now the Question i need required Fields how can i make
a examination if the required Fields are empty an when they are empty the script goes back to case 1

how can i realize

german rookie

10:39 pm on Feb 7, 2006 (gmt 0)

10+ Year Member



really no on an idea? to make the required fields to check before i go to case 2?

coopster

8:18 pm on Feb 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You can code it into your script. Edit check each and every submitted value to make sure it is what you are expecting before passing it on to the next step.