multiple page forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

multiple page forms

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

Post 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. :(
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

can someone explain how to do this i need to do this too.
thanks alot!
ryanlwh
Forum Commoner
Posts: 84
Joined: Wed Sep 14, 2005 1:29 pm

Post 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']; ?>'>
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

and then on the next form page type what?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

what would the username be used for.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post 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!
Post Reply