Accurax Posted May 23, 2006 Share Posted May 23, 2006 Hi, this is a related subject to a previous post I made a few weeks back, But since the question is now become more specific, and, i also now know what i am trying to do, i felt it needed a new topic.I am currently (still) trying to build this form to collect information to allow me to write CV's for people. You can see it [a href=\"http://members.lycos.co.uk/cmbtest\" target=\"_blank\"]here[/a].Due to the fact that the form is going to be excedingly long, i need to break it down into several smaller chunks.To do this i've decided to use hidden fields to store the info from the previous form page(s) and submitt them all together.What im basically looking for (in an ideal world) is a decent tutorial on how to acomplish this. I've spent quite some time looking, and allthough i understand how to create hidden fields, and how to have them store the information im missing some more basic knowledge thats stopping me from geting started.Currently, as you will see if you view my site <above>, I have a simple one page form with a submit button that $_POST 's the gathered information to my email inbox;Now, in order to make the multiple page's work i think i need to do the following (confirmation appreciated)1) Remove the Section of code that sends / formatts the email from all but the final page of the form. 2)Add a link from the first page to the second..... second to third etc, this will replace the "submit" button.3)Code the hidden fields into all pages after the first.4) Add the submitt button on the final page.Assuming the above is methodically correct, i have a question;*How do i get from page 1 to page 2 to page 3 etc .... is there a special method i must use... or will a simple link work?Silly question really .... but there are probably more to come... to be fair its probably preferable if someone could point me at a decent turtorial dealing with hidden fields when applied to a multi-page form.... although it may be a somewhat specific requirement for a turorial [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Any and all hellp appreciated Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/ Share on other sites More sharing options...
Orio Posted May 23, 2006 Share Posted May 23, 2006 If you use just a link to move to the next page, the info wont be sent.What basicly you want to do is a set of forms, that "remmber" using hidden field.Let's have an example of two pages (+one that sends the mail) that the first one asks for your name, and the second for your age:First page will be a normal html page:[code]<html><head><title>page1.php</title></head><body><form action="page2.php" method="POST">You name:<br><input type="text" name="name"><br><input type="submit" value="Continue"></form></body></html>[/code]The second page will get the the name from page1.php and "remmber" it using a hidden field. Then It'll ask for the age:[code]<?php$name=$_POST['name'];?><html><head><title>page2.php</title></head><body><form action="page3.php" method="POST">You age:<br><input type="text" name="age"><br><input type="hidden" name="name" value="<?php echo($name); ?>"><input type="submit" value="Continue"></form></body></html>[/code]Now, page3.php will recive both the age and the name, and can email them:[code]$name=$_POST['name'];$age=$_POST['age'];$subject="New CV";$email="my@email.com";$msg="New CV! \n Name: ".$name."\n Age:".$age."\n wants a CV";mail($email,$subject,$msg);echo("Mail sent. Thank you.");[/code]Now as you see, you need to send the info from page to page with a form, and have it "remmbered" using hidden fields that PHP echos the last page's information into them.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38227 Share on other sites More sharing options...
Accurax Posted May 23, 2006 Author Share Posted May 23, 2006 [!--quoteo(post=376319:date=May 23 2006, 08:07 AM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ May 23 2006, 08:07 AM) [snapback]376319[/snapback][/div][div class=\'quotemain\'][!--quotec--]Now, page3.php will recive both the age and the name, and can email them:[code]$name=$_POST['name'];$age=$_POST['age'];$subject="New CV";$email="my@email.com";$msg="New CV! \n Name: ".$name."\n Age:".$age."\n wants a CV";mail($email,$subject,$msg);echo("Mail sent. Thank you.");[/code]Now as you see, you need to send the info from page to page with a form, and have it "remmbered" using hidden fields that PHP echos the last page's information into them.Orio.[/quote]Wow, thanks mate,Ive pretty much started recoding my form from scratch, as its easier to get my head around it that way. I can now manage to get the form to successfuly skip from page 1 - page2 - page3 .... but, on arrival at page 3 (on localhost), i get a funny message;[code]Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\wamp\www\test\practice forms\form3.php on line 32Mail sent. Thank you.[/code]I have basically inserted the code you suggested, but i have surrounded it with <? ... ?> tags, as it wouldnt work at all without them, is this correct?Is the 3rd page meant to simply display a rundown of the filled in fields after posting them?I think im getting there... i fear i may have been severly over-complicating things before.... just a little push pls [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38233 Share on other sites More sharing options...
Orio Posted May 23, 2006 Share Posted May 23, 2006 I dont really understand in these issues, but it seems that on of the php.ini (one of the basic files in a PHP server) settings are not right.Maybe one of the Gurus here can help?Orio. Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38335 Share on other sites More sharing options...
Accurax Posted May 23, 2006 Author Share Posted May 23, 2006 I think it was just an issue with wamp ... it works fine (over 2 pages) on my remote server [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] However, i have another little problem you might be able to help me with.Im pretty sure its something ridiculously simple.... but after 2 hours i still cant get it working.. and im geting pretty ##~@. Bleep ... off [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] I need 4 pages to my form, i have them all coded out... now, and sorry if this is odd.Form2 wil recieve data into its hidden fields from Form1Form3 will recive from form2Form4 will recieve from form3but the data int being carried... so on Form3 for example, allthough the hidden fields exist the value is set to "" aka bugger all.Surly the idea is to get the data to carry through from form 1 all the way to the end in order to process it ?Any idea's? ... i can post the code if u need... please ask b4 i do as its quite long now [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38348 Share on other sites More sharing options...
Orio Posted May 23, 2006 Share Posted May 23, 2006 Yeah, some code will be good, its hard without the code.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38354 Share on other sites More sharing options...
Accurax Posted May 23, 2006 Author Share Posted May 23, 2006 Ok, ill do the code for form1,2 & 3 .... I assume the problem with from 4 is the same, so no need to repeat code unless u specifically need it.... do my bit for the bandwidth [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] I have omitted unnessecary Html in the following code;Form #1[code] <form action="form2.php" method="POST"> <div align="center"> <table width="0" height="0" border="0" align="center" cellpadding="5" cellspacing="0" class="cvtable"> <tr> <td height="35" class="topleft"> </td> <td class="topright"><div align="center"><span class="style1">Please enter your information, click continue to proceed.</span></div></td> </tr> <tr> <td width="150"><p align="left"><b>Your First Name:</b></td> <td width="300"><input name="firstname" type ="text" size="15" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Middlename:</b></td> <td width="300"><input name="middlename" type ="text" size="15" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Surname:</b></td> <td width="300"><input name="surname" type ="text" size="15" maxlength="25"></td> </tr> <tr> <td width="150"><div align="center"> <div align="left"><b>Your Sex:</b></div></td> <td width="300"><input name="sex" type="radio" value="male"/><b>Male</b> <input name="sex" type="radio" value="female"/><b>Female</b></td> </tr> <tr> <td width="150"><div align="left"> <div align="left"><b>Your Marital Status:</b></div></td> <td width="300"><input name="marital" type="radio" value="single"/><b>Single</b> <input name="marital" type="radio" value="married"/><b>Married</b></td> </tr> <tr> <td width="150"><div align="left"><b>Number of Children:</b></div></td> <td width="300"><input name="children" type ="text" size="4" maxlength="2"></td> </tr> <tr> <td width="150"><div align="left"><b>Date Of Birth:</b></div></td> <td width="300"> <select name="month"> <option>January <option>Febuary <option>March <option>April <option>May <option>June <option>July <option>August <option>September <option>October <option>November <option>December </select> <select name="day"> <option>1st <option>2nd <option>3rd <option>4th <option>5th <option>6th <option>7th <option>8th <option>9th <option>10th <option>11th <option>12th <option>13th <option>14th <option>15th <option>16th <option>17th <option>18th <option>19th <option>20th <option>21st <option>22nd <option>23rd <option>24th <option>25th <option>26th <option>27th <option>28th> <option>29th <option>30th <option>31st </select> <select name="year"> <option>1930 <option>1931 <option>1932 <option>1933 <option>1934 <option>1935 <option>1936 <option>1937 <option>1938 <option>1939 <option>1940 <option>1941 <option>1942 <option>1943 <option>1944 <option>1945 <option>1946 <option>1947 <option>1948 <option>1949 <option>1950 <option>1951 <option>1952 <option>1953 <option>1954 <option>1955 <option>1956 <option>1957 <option>1958 <option>1959 <option>1960 <option>1961 <option>1962 <option>1963 <option>1964 <option>1965 <option>1966 <option>1967 <option>1968 <option>1969 <option>1970 <option>1971 <option>1972 <option>1973 <option>1974 <option>1975 <option>1976 <option>1977 <option>1978 <option>1979 <option>1980 <option>1981 <option>1982 <option>1983 <option>1984 <option>1985 <option>1986 <option>1987 <option>1988 <option>1989 <option>1990 <option>1991 <option>1992 <option>1993 <option>1994 <option>1995 <option>1996 <option>1997 <option>1998 <option>1999 <option>2000 <option>2001 <option>2002 <option>2003 <option>2004 <option>2005 <option>2006 </select> </td> <tr> <td> </td> <td> </td> </tr> <tr> <td class="bottomleft"> </td> <td class="bottomright"><input name="submit" type="submit" value="Continue" /> </td> </tr> </table> </p> </div> </form> <p align="center"> </p> </div> <div class="clearer"></div></div><div id="divFooter"><a href="../../index.htm">Home</a> <a href="../../Business%20Services/Business.htm">Business</a> <a href="../../CVs/CV.htm">Cv services</a> <a href="../../Location/Location.htm">Location</a> <a href="../../Contact%20Us/ContactUs.htm">Contact Us</a> </div></body></html>[/code]The above form passes the information into the hidden fields on number 2 without issue:Form #2[code] <?php$firstname=$_POST['firstname'];$middlename=$_POST['middlename'];$surname=$_POST['surname'];$sex=$_POST['sex'];$marital=$_POST['marital'];$children=$_POST['children'];$month=$_POST['month'];$day=$_POST['day'];$year=$_POST['year'];?> <input type="hidden" name="firstname" value="<?php echo($firstname); ?>"> <input type="hidden" name="middlename" value="<?php echo($middlename); ?>"> <input type="hidden" name="surname" value="<?php echo($surname); ?>"> <input type="hidden" name="sex" value="<?php echo($sex); ?>"> <input type="hidden" name="marital" value="<?php echo($marital); ?>"> <input type="hidden" name="children" value="<?php echo($children); ?>"> <input type="hidden" name="month" value="<?php echo($month); ?>"> <input type="hidden" name="day" value="<?php echo($day); ?>"> <input type="hidden" name="year" value="<?php echo($year); ?>"><form action="form3.php" method="POST"> <div align="center"> <table width="" border="0" cellpadding="5" cellspacing="0" class="cvtable"> <tr> <td class="topleft"> </td> <td class="topright"> </td> </tr> <tr> <td width="150"><p align="left"><b>Your Address:</b></td> <td width="300"><input name="address1" type ="text" size="40" maxlength="45"></td> </tr> <tr> <td width="150"><p align="left"></td> <td width="300"><input name="address2" type ="text" size="40" maxlength="45"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Town:</b></td> <td width="300"><input name="town" type ="text" size="30" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Postcode:</b></td> <td width="300"><input name="postcode" type ="text" size="10" maxlength="12"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Mobile No':</b></td> <td width="300"><input name="mobile" type ="text" size="20" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Home No':</b></td> <td width="300"><input name="home" type ="text" size="20" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Work No':</b></td> <td width="300"><input name="work" type ="text" size="20" maxlength="25"></td> </tr> <tr> <td width="150"><div align="center"> <div align="left"><b>Prefered method of contact:</b></div></td> <td width="300"><input name="prefered" type="radio" value="mobile"/><b>Mobile</b> <input name="prefered" type="radio" value="home"/><b>Home</b> <input name="prefered" type="radio" value="work"/><b>Work</b> </td> </tr> <tr> <td width="150"><p align="left"><b>Your E-Mail:</b></td> <td width="300"><input name="email" type ="text" size="20" maxlength="50"></td> </tr> <tr> <td width="150"><div align="left"> <div align="left"><b>Can We Send drafts / revisions to this email address?:</b></div></td> <td width="300"><input name="canmail" type="radio" value="yes"/><b>Yes</b> <input name="canmail" type="radio" value="no"/><b>No</b></td> </tr> <tr> <td class="bottomleft"> </td> <td class="bottomright"><input name="submit" type="submit" value="Continue" /></td> </tr> </table> </div></form> <p align="center"> </div> <div class="clearer"></div></div><div id="divFooter"><a href="../../index.htm">Home</a> <a href="../../Business%20Services/Business.htm">Business</a> <a href="../../CVs/CV.htm">Cv services</a> <a href="../../Location/Location.htm">Location</a> <a href="../../Contact%20Us/ContactUs.htm">Contact Us</a> </div></body></html>[/code]now, the information that is[b] entered[/b] onto form #2 is passed correctly into the hidden fields on form #3... but the value's of the hidden fields from form #1 is not passed on;Form #3[code] <?php$firstname=$_POST['firstname'];$middlename=$_POST['middlename'];$surname=$_POST['surname'];$sex=$_POST['sex'];$marital=$_POST['marital'];$children=$_POST['children'];$month=$_POST['month'];$day=$_POST['day'];$year=$_POST['year'];$address1=$_POST['address1'];$address2=$_POST['address2'];$town=$_POST['town'];$postcode=$_POST['postcode'];$mobile=$_POST['mobile'];$home=$_POST['home'];$work=$_POST['work'];$prefered=$_POST['prefered'];$email=$_POST['email'];$canmail=$_POST['canmail'];?> <input type="hidden" name="firstname" value="<?php echo($firstname); ?>"> <input type="hidden" name="middlename" value="<?php echo($middlename); ?>"> <input type="hidden" name="surname" value="<?php echo($surname); ?>"> <input type="hidden" name="sex" value="<?php echo($sex); ?>"> <input type="hidden" name="marital" value="<?php echo($marital); ?>"> <input type="hidden" name="children" value="<?php echo($children); ?>"> <input type="hidden" name="month" value="<?php echo($month); ?>"> <input type="hidden" name="day" value="<?php echo($day); ?>"> <input type="hidden" name="year" value="<?php echo($year); ?>"> <input type="hidden" name="address1" value="<?php echo($address1); ?>"> <input type="hidden" name="address2" value="<?php echo($address2); ?>"> <input type="hidden" name="town" value="<?php echo($town); ?>"> <input type="hidden" name="postcode" value="<?php echo($postcode); ?>"> <input type="hidden" name="mobile" value="<?php echo($mobile); ?>"> <input type="hidden" name="home" value="<?php echo($home); ?>"> <input type="hidden" name="work" value="<?php echo($work); ?>"> <input type="hidden" name="prefered" value="<?php echo($prefered); ?>"> <input type="hidden" name="email" value="<?php echo($email); ?>"> <input type="hidden" name="canmail" value="<?php echo($canmail); ?>"><form action="formend.php" method="POST"> <div align="center"> <table width="" border="0" align="center" cellpadding="5" cellspacing="0" class="cvtable"> <tr> <td class="topleft"> </td> <td class="topright"> </td> </tr> <tr> <td width="150"><p align="left"><b>Your Address:</b></td> <td width="300"><input name="address1" type ="text" size="40" maxlength="45"></td> </tr> <tr> <td width="150"><p align="left"></td> <td width="300"><input name="address2" type ="text" size="40" maxlength="45"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Town:</b></td> <td width="300"><input name="town" type ="text" size="30" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Postcode:</b></td> <td width="300"><input name="postcode" type ="text" size="10" maxlength="12"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Mobile No':</b></td> <td width="300"><input name="mobile" type ="text" size="20" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Home No':</b></td> <td width="300"><input name="home" type ="text" size="20" maxlength="25"></td> </tr> <tr> <td width="150"><p align="left"><b>Your Work No':</b></td> <td width="300"><input name="work" type ="text" size="20" maxlength="25"></td> </tr> <tr> <td width="150"><div align="center"> <div align="left"><b>Prefered method of contact:</b></div></td> <td width="300"><input name="prefered" type="radio" value="mobile"/><b>Mobile</b> <input name="prefered" type="radio" value="home"/><b>Home</b> <input name="prefered" type="radio" value="work"/><b>Work</b> </td> </tr> <tr> <td width="150"><p align="left"><b>Your E-Mail:</b></td> <td width="300"><input name="email" type ="text" size="20" maxlength="50"></td> </tr> <tr> <td width="150"><div align="left"> <div align="left"><b>Can We Send drafts / revisions to this email address?:</b></div></td> <td width="300"><input name="canmail" type="radio" value="yes"/><b>Yes</b> <input name="canmail" type="radio" value="no"/><b>No</b></td> </tr> <tr> <td class="bottomleft"> </td> <td class="bottomright"><input name="submit" type="submit" value="Continue" /></td> </tr> </table> </div></form> <p align="center"> </div> <div class="clearer"></div></div><div id="divFooter"><a href="../../index.htm">Home</a> <a href="../../Business%20Services/Business.htm">Business</a> <a href="../../CVs/CV.htm">Cv services</a> <a href="../../Location/Location.htm">Location</a> <a href="../../Contact%20Us/ContactUs.htm">Contact Us</a> </div></body></html>[/code]I hope that helps a little with solving this ... i figure that i must have something to do with the hidden fields not being posted to the next form... but i dont really see why [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] Thanks for your time mate... your help is really appreciated [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38362 Share on other sites More sharing options...
.josh Posted May 24, 2006 Share Posted May 24, 2006 your hidden input types are not inside your form tags. Quote Link to comment https://forums.phpfreaks.com/topic/10259-hidden-field-assistance/#findComment-38423 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.