Page 1 of 1

multiple page forms

Posted: Wed Sep 07, 2005 2:16 am
by burnhallian
dear all !

can anyone help me how to make a form with multiple pages. I would use different tables so with the id from first table then i will insert data from formsinto other tables using the same id. but im not sure how to do that and how to pass on the id. can some help me out or does anyone have something related to this that can help me ?

thanx

Posted: Wed Sep 07, 2005 2:43 am
by s.dot
Hmm.. why would a form need multiple pages?

Perhaps like a multi-step form.. like complete step 1, then go on to step 2, etc..

Or maybe you mean, submit a form, then process/show results on a different page.

Either way there are several methods to retain the ID #.

You could take a variable onto your URL ($_GET)
You could just post the data, including the id ($_POST)
You could even store in a database and retrieve it on the next page

Posted: Tue Sep 13, 2005 8:29 pm
by burnhallian
Thanx a lot scrotaye for ur reply !

actually the form is supposed to b like page 1, then 2 and so on. im not still getting it, can u plzz clearify how to create forms like that. im a new bie so having difficulties. :(

Posted: Tue Sep 13, 2005 8:38 pm
by josh
if your issue is just maintaining an id from page to page, why not either use php's build in session management, or just ouput the id in a hidden form element?

Posted: Wed Sep 14, 2005 8:32 pm
by nickman013
can someone explain how to do this i need to do this too.
thanks alot!

Posted: Wed Sep 14, 2005 11:40 pm
by ryanlwh
whenever you want to save the info for another form, use a hidden input field

Code: Select all

<input type='hidden' name='id' value='<?php echo $_POST['id']; ?>'>

Posted: Thu Sep 15, 2005 1:27 pm
by nickman013
and then on the next form page type what?

Posted: Thu Sep 15, 2005 1:44 pm
by John Cartwright
scrotaye wrote:Hmm.. why would a form need multiple pages?
You could take a variable onto your URL ($_GET)
You could just post the data, including the id ($_POST)
You could even store in a database and retrieve it on the next page
Scrotaye hit it on the nail.

I generally don't like to store things in hidden fields, because I simply don't trust the client side aspect of my applications :lol:. What I would suggest is store the previous steps of the form inside sessions.

Code: Select all

$_SESSION['steps'][1] = array(
   'username' => $_POST['username'],
   'email' => $_POST['email'],
);

Code: Select all

$_SESSION['steps'][2] = array(
   'address' => $_POST['address'],
   'address' => $_POST['address'],
);
That is basically how I would structure the data. Of course everything should be validated, because using unsanitized data may be dangerous.
To determine what step the form is on, I would be passing on a $_GET variable and depending on what the value of this variable, load appropriate forms.

http://localhost/formtest.php?step=1

To determine how to execute specific blocks of code, you should look into switch() or if()

A simple version would look like

Code: Select all

//check to see if step variable exists
$step = (isset($_GET['step']) ? (int)$_GET['step'] : 0);

switch ($step) {
   case (0) {
      //display first step
      break;

   case (1) {
      //display second step
      break;

   case (2) {
      //display third step
      break;
}
This form is still open for users skipping their steps, so in each step I would make sure all the data is in the array before letting them see the next form.. I think that should get you started.

Posted: Thu Sep 15, 2005 8:05 pm
by nickman013
what would the username be used for.

Posted: Thu Sep 15, 2005 9:29 pm
by nickman013
look mybee you can help me because i am not to good with php.

i have these 2 formsl.
form 1 :arrow:

Code: Select all

<form action="http://wsc1.nyesonline.net/processors/order.php" method="post">
  <tbody>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP">
    <p ALIGN="CENTER"><b><font SIZE="2"><font FACE="Georgia">Qty</font></font></b></p>
    </td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP">
    <p ALIGN="CENTER"><b><font SIZE="2"><font FACE="Georgia">Item #</font></font></b></p>
    </td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP">
    <p ALIGN="CENTER"><b><font SIZE="2"><font FACE="Georgia">Description</font></font></b></p>
    </td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP">
    <p ALIGN="CENTER"><b><font SIZE="2"><font FACE="Georgia">Price Each</font></font></b></p>
    </td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty1" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product1a" SIZE="5" MAXLENGTH="8" /></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product1b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price1" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty2" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product2a" SIZE="5" MAXLENGTH="8" /></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product2b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price2" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty3" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product3a" SIZE="5" MAXLENGTH="8" /></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product3b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price3" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty4" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product4a" SIZE="5" MAXLENGTH="8" /></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product4b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price4" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty5" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product5a" SIZE="5" MAXLENGTH="8" /></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product5b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price5" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty6" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product6a" SIZE="5" MAXLENGTH="8" /></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product6b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price6" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty7" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product7a" SIZE="5" MAXLENGTH="8"></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product7b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price7" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
     <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty8" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product8a" SIZE="5" MAXLENGTH="8"></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product8b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price8" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
   <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty9" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product9a" SIZE="5" MAXLENGTH="8"></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product9b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price9" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
   <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty10" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product10a" SIZE="5" MAXLENGTH="8"></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product10b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price10" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
   <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty11" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product11a" SIZE="5" MAXLENGTH="8"></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product11b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price11" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
   <tr>
    <td WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><input TYPE="TEXT" NAME="qty12" SIZE="3" MAXLENGTH="2" /></p>
    </center></td>
    <td WIDTH="10%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product12a" SIZE="5" MAXLENGTH="8"></p>
    </center></td>
    <td WIDTH="73%" BGCOLOR="#F5DEB3" VALIGN="TOP"><center>
    <p ALIGN="CENTER">
    <input TYPE="TEXT" NAME="product12b" SIZE="100" MAXLENGTH="250" /></p>
    </center></td>
    <td WIDTH="12%" BGCOLOR="#F5DEB3" VALIGN="CENTER"><center>
    <p ALIGN="CENTER"><font FACE="Georgia">$<input TYPE="TEXT" NAME="price12" SIZE="7" MAXLENGTH="6" /></font></p>
    </center></td>
  </tr>
  </tr>
  <tr>
    <td COLSPAN="2" WIDTH="5%" BGCOLOR="#F5DEB3" VALIGN="TOP">
    </td>
    <td COLSPAN="2" BGCOLOR="#F5DEB3" VALIGN="CENTER">
    <div ALIGN="RIGHT">
      <p ALIGN="RIGHT">
      <input TYPE="SUBMIT" VALUE="Send Order!!!" />
</form>
and i also have this one

Code: Select all

<form METHOD="POST" ACTION="http://wsc1.nyesonline.net/processors/team.php">
Name: <input type="text" name="name"> <br>
Address: <input type="text" name="address"> <br>
Phone Number: <input type="text" name="phone"> <br>
E-Mail Address: <input type="text" name="email"> <br>
Comments: <br> <TEXTAREA NAME="comments" ROWS=6 COLS=40>
</TEXTAREA><br>
<input type="submit" value="Submit"> &nbsp; <input type="reset" value="Reset">
</form>
they need to be seperated but come back as one email. i just need to know exactly what i have to put on the pages. besides the form and stuff. thanks!