By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

How to split a long form into two pages and have all field submit at the end.

P: 1
Hi ALL,

I dont know much about php, but have got a long form that i need to split into two pages, i want to have the inputs from the page 1 past to page 2 and all submitted via email at the end. I am really stock on this one. I have managed to split the form and I have used the php 'GET' and i could see the inputs at in url. Please any help will be most appreciated.

Please find below the form below/
Expand|Select|Wrap|Line Numbers
  1. <form action="/form2.php" method="get" name="entery" id="entery" onsubmit="return checkFields()">
  2.  
  3.  
  4.  
  5. <fieldset>
  6. <legend>About you:
  7.  
  8. </legend>
  9.  
  10.  
  11. <table border="0" bordercolor="#999999" cellpadding="0" cellspacing="0" width="530">
  12.  
  13. <td>Residential Status:<br>
  14.  
  15.  
  16.  
  17.  
  18.  
  19. <select style="width: 140px;" name="ResidentialStatus" id="ResidentialStatus" size="1" onchange="if ((this.options[this.selectedIndex].value=='StudentAcc')||(this.options[this.selectedIndex].value=='Tenant')||(this.options[this.selectedIndex].value=='LivingWP')) document.location.href='unsecured.html'; checkFieldBack(this)">
  20. <option value="" selected="selected">-
  21. Select - </option>
  22.  
  23. <option value="homeowner">Homeowner with
  24. mortgage</option>
  25. <option value="Tenant">Own home outright</option>
  26. <option value="StudentAcc">Student Acc.</option>
  27. <option value="Tenant">Tenant</option>
  28. <option value="LivingWP">Living w/parents</option>
  29. </select>
  30. </td>
  31.  
  32. <td>Loan Purpose: <br>
  33.  
  34.  
  35. <select name="Loan_purpose" id="Loan_purpose">
  36. <option value="" selected="selected">-Please
  37. Select-</option>
  38.  
  39. <option value="Car Loan">Car Loan</option>
  40. <option value="Home Improvement">Home
  41. Improvement</option>
  42. <option value="Consolidation">Consolidation</option>
  43. <option value="Holiday">Holiday</option>
  44. <option value="Overdraft">Overdraft</option>
  45. <option value="Mortgage">Mortgage</option>
  46.  
  47. <option value="Remortgage">Remortgage</option>
  48. <option value="Business Loan">Business Loan</option>
  49. <option value="Other">Other</option>
  50. </select>
  51.  
  52.  
  53.  
  54. </td>
  55.  
  56.  
  57. <td>Loan Amount: <br>
  58.  
  59. <select name="Loan Amount" style="width: 140px;">
  60. <option value="6000">&pound;6,000</option>
  61. <option value="7000">&pound;7,000</option>
  62. <option value="8000">&pound;8,000</option>
  63.  
  64.  
  65. <option value="90000">&pound;90,000</option>
  66.  
  67. <option value="100000">&pound;100,000</option>
  68. <option value="More than 100000">&pound;100,000+</option>
  69. </select>
  70.  
  71. </td>
  72.  
  73. </table>
  74. </p>
  75.  
  76.  
  77.  
  78. <input type="image" value="submit" src="../i/1x1.gif" width="100" height="30">
  79.  
  80.  
  81.  
  82. form2
  83.  
  84.  
  85. <form action="/formmail.php" method="post" name="form" id="form" onsubmit="return checkForm()">
  86.  
  87.  
  88.  
  89. <fieldset><legend>About you: </legend>
  90.  
  91.  
  92. <table border="0" bordercolor="#999999" cellpadding="0" cellspacing="0" width="530">
  93.  
  94.  
  95.  
  96. <tbody>
  97.  
  98.  
  99.  
  100. <td width="180"><br>
  101.  
  102.  
  103.  
  104. First Name:&nbsp;<br>
  105.  
  106.  
  107.  
  108.  
  109. <select class="list_menu" id="Loans_title1" style="width: 40px;" size="1" name="Loans_title1" onchange="checkPMrs(this.value)">
  110. <option value="Mr" selected="selected">Mr</option>
  111. <option value="Mrs">Mrs</option>
  112. <option value="Miss">Miss</option>
  113. <option value="Ms">Ms</option>
  114. </select>
  115.  
  116.  
  117.  
  118. <input id="First_Name" style="width: 100px;" maxlength="20" size="22" name="First_Name" onkeyup="checkFieldBack(this)"></td>
  119.  
  120.  
  121.  
  122. <td width="180">Surname:<br>
  123.  
  124.  
  125.  
  126. <input id="Surname" style="width: 140px;" maxlength="20" size="22" name="Surname" onkeyup="checkFieldBack(this)"></td>
  127.  
  128.  
  129. <td width="180">Date Of Birth:<br>
  130.  
  131.  
  132. <select class="list_menu" id="Date_of_Birth_Day" style="width: 45px;" name="Date_of_Birth_Day" onchange="checkFieldBack(this)">
  133. <option value="" selected="selected">dd</option>
  134. <option value="01">01</option>
  135. <option value="02">02</option>
  136.  
  137. <option value="03">03</option>
  138. <option value="04">04</option>
  139. <option value="05">05</option>
  140. <option value="06">06</option>
  141. <option value="07">07</option>
  142. <option value="08">08</option>
  143.  
  144.  
  145.  
  146. <option value="1908">1908</option>
  147. </select>
  148.  
  149. </td>
  150.  
  151.  
  152. </tr>
  153.  
  154. <td><br>
  155.  
  156.  
  157.  
  158. Mother's Maiden name:<br>
  159.  
  160.  
  161.  
  162. <input id="Mothers_Maiden_Name" style="width: 140px;" name="Mothers_Maiden_Name" onkeyup="checkFieldBack(this)"></td>
  163.  
  164.  
  165.  
  166. <td valign="top">Job Status:<br>
  167.  
  168.  
  169. <select id="Job_Status" name="Job_Status" style="width: 140px;">
  170.  
  171. <option value="">- Select -</option>
  172. <option value="Full Time" selected="selected">Full
  173. Time</option>
  174. <option value="Part Time">Part Time</option>
  175. <option value="Self Employed">Self Employed</option>
  176. <option value="Retired">Retired</option>
  177. <option value="Unemployed">Unemployed</option>
  178.  
  179. <option value="Homemaker">Homemaker</option>
  180. </select>
  181.  
  182.  
  183. </td>
  184.  
  185. <td valign="top">Occupation:<br>
  186.  
  187.  
  188. <input id="Occupation" style="width: 140px;" maxlength="50" name="Occupation" onkeyup="checkFieldBack(this)"></td>
  189.  
  190.  
  191. </tr>
  192.  
  193.  
  194. <td><br>
  195.  
  196.  
  197.  
  198. Yearly Income:<br>
  199.  
  200.  
  201.  
  202. <select id="Yearly_Income" name="Yearly_Income" style="width: 140px;" onchange="checkFieldBack(this)">
  203. <option value="" selected="selected">-
  204. Select -</option>
  205. <option value="1000">&pound;1,000</option>
  206.  
  207. <option value="2000">&pound;2,000</option>
  208. <option value="3000">&pound;3,000</option>
  209. <option value="4000">&pound;4,000</option>
  210. <option value="5000">&pound;5,000</option>
  211. <option value="6000">&pound;6,000</option>
  212. <option value="7000">&pound;7,000</option>
  213.  
  214.  
  215. <option value="17000">&pound;17,000</option>
  216. <option value="18000">&pound;18,000</option>
  217. <option value="19000">&pound;19,000</option>
  218.  
  219.  
  220. <option value="100000">&pound;100,000</option>
  221. </select>
  222.  
  223.  
  224. </td>
  225.  
  226.  
  227.  
  228. <td width="180">Property Value:<br>
  229.  
  230.  
  231. <select id="Property_Value" style="width: 140px;" maxlength="50" name="Property_Value" onchange="checkFieldBack(this)">
  232. <option value="" selected="selected">-
  233. Select -</option>
  234. <option value="50000">&pound;50,000</option>
  235. <option value="60000">&pound;60,000</option>
  236. <option value="70000">&pound;70,000</option>
  237.  
  238.  
  239.  
  240. <option value="980000">&pound;980,000</option>
  241. <option value="990000">&pound;990,000</option>
  242. <option value="1000000">&pound;1,000,000</option>
  243. </select>
  244.  
  245.  
  246.  
  247. </td>
  248.  
  249.  
  250. <td width="180"> Mortgage Balance:<br>
  251.  
  252.  
  253.  
  254.  
  255.  
  256. <select id="Mortgage_Outstanding" style="width: 140px;" name="Mortgage_Outstanding" onchange="checkFieldBack(this)">
  257. <option value="" selected="selected">-
  258. Select -</option>
  259. <option value="1000">&pound;1,000</option>
  260.  
  261. <option value="2000">&pound;2,000</option>
  262. <option value="3000">&pound;3,000</option>
  263. <option value="4000">&pound;4,000</option>
  264. <option value="5000">&pound;5,000</option>
  265. <option value="6000">&pound;6,000</option>
  266. <option value="7000">&pound;7,000</option>
  267.  
  268.  
  269. <option value="975000">&pound;975,000</option>
  270. <option value="1000000">&pound;1,000,000</option>
  271. </select>
  272.  
  273.  
  274.  
  275. </td>
  276.  
  277.  
  278.  
  279.  
  280.  
  281. </tr>
  282.  
  283.  
  284.  
  285.  
  286.  
  287. </tbody>
  288.  
  289.  
  290. </table>
  291.  
  292.  
  293. </fieldset>
  294.  
  295.  
  296.  
  297.  
  298.  
  299. <div id="finishButton">
  300.  
  301.  
  302. <p>&nbsp; &nbsp; &nbsp;All Done? Click
  303. "FINISH" to get your quote
  304. &raquo;&nbsp; <input name="submit" value="Finish!" type="submit"></p></form>



sorry this seems to be a very long form.
Jul 19 '07 #1
Share this Question
Share on Google+
3 Replies


P: 22
Hey,
Would it be possible to send half of it to the next page VIA post, then set them as variables then do something like (Sending it to next page)
[php]
<?php
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];
echo '<form method=POST action=something.php?var1=' . $var1 .'&var2=' . $var2 .' >The second page form would go here </form>';
?>
[/php]
That would send half via GET and half via POST allowing you to continue the trend. Although GET isn't very secure So if your using it for private data it may not be the best. But for general purposes it should be fine. Only easy way I know unless you want to store it in a cookie/session/file until the last page.
~Tyler
Jul 20 '07 #2

P: 1
Hello,

I'm an avid Family Guy Fan, have made my own website - see my signature if you want to view it.

Just browsing the forum as I am interested in it.

Hoping to get to make some ebuddies here!
Jan 23 '11 #3

HaLo2FrEeEk
100+
P: 404
Send them both with POST and on the second page, simply loop through the POST array and echo out inputs wth type="hidden". For example, write your first page form and set its method to post, ten on the second page, do something like this, AFTER you're already echoed the form start tag:

Expand|Select|Wrap|Line Numbers
  1. foreach($_POST as $name=>$value) {
  2.   echo "<input type=\"hidden\" name=\"".$name."\" id=\"".$name."\" value=\"".$value."\">\n";
  3.   }
This will result in each of the values from the first page essentially being auto-populated on the second form, but they're hidden, so they don't actually appear anywhere on the page. Keep in mind, however, that the user could simply use something like Developer Tools in IE8+ and change the values in the hidden inputs, but they could do that if you used tscott's method too, and it's a bad idea to submit any part of your form with GET, especially if it contains or controls personal information.
Jan 24 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.