Leadwing Posted October 19, 2007 Share Posted October 19, 2007 Hi there, I have a form with multiple pages. In order to pass data from the the first page of a form to the second page, i understand you need to use... <input type="hidden" name="$_POST['name']" /> ...in the second page. But it doesnt seem to work (when i try to display it on the third page) Also how do I get the data to go through a "process", which is like, in between the form pages? Helpsies would be greatly apreciated Quote Link to comment Share on other sites More sharing options...
mattal999 Posted October 19, 2007 Share Posted October 19, 2007 <input type="hidden" name="fieldname" value="" . $_POST['name'] . ""> Quote Link to comment Share on other sites More sharing options...
thebadbad Posted October 19, 2007 Share Posted October 19, 2007 If I understand you correct, I would do the following: Lets say pages are page1.php, page2.php and page3.php, and I guess you want to have the form on page 3 to send all the information entered since page 1. If we have one text field on each page, and the first is for your given name, second for your surname and third for your age, it could look like this: page1.php: ... <form action="page2.php" method="post"> <fieldset> <legend>Personal information</legend> <label for="givenname">Given name:</label> <input id="givenname" name="givenname" type="text" /> </fieldset> <input type="submit" value="Go to page 2" /> </form> ... page2.php: ... <form action="page3.php" method="post"> <fieldset> <legend>Personal information</legend> <label for="surname">Surname:</label> <input id="surname" name="surname" type="text" /> <input type="hidden" name="givenname" value="<?php echo $_POST['givenname']; ?>" /> </fieldset> <input type="submit" value="Go to page 3" /> </form> ... page3.php: ... <form action="lastpage.php" method="post"> <fieldset> <legend>Personal information</legend> <label for="age">Age:</label> <input id="age" name="age" type="text" /> <input type="hidden" name="givenname" value="<?php echo $_POST['givenname']; ?>" /> <input type="hidden" name="surname" value="<?php echo $_POST['surname']; ?>" /> </fieldset> <input type="submit" value="Send my information" /> </form> ... lastpage.php would be the page you eventually send all the information to. Good luck Quote Link to comment Share on other sites More sharing options...
Leadwing Posted October 19, 2007 Author Share Posted October 19, 2007 Thanks, that works nicely One last thing... I have a page in between page 2 and 3, its a code to redirect to page 3 or another page (I wont go into details). But my question is how can I use that <input type="hidden" name="givenname" value="<?php echo $_POST['givenname']; ?>" /> On a page which doesn't have a form? - Just an if/elseif command? Hope that makes sense. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted October 19, 2007 Share Posted October 19, 2007 That depends on what you want to do with the data. If you want to redirect it along, you should look into sessions, which can store data temporarily (and thus across pages, not depending on forms and text fields). In your example you could store the form data in sessions, like this: page_in_between_2_and_3.php ... <?php // storing the given name from page 1 and 2 $_SESSION['givenname'] = $_POST['givenname']; // storing the surname from page 2 $_SESSION['surname'] = $_POST['surname']; ?> ... And you will then be able to extract the data again on whatever page you like, like this: <?php echo $_SESSION['givenname']; ?> I recommend you to read this short article on sessions: http://www.tizag.com/phpT/phpsessions.php, because you can't store any session data without first starting a session. Just read it, or your code wont work =) Quote Link to comment Share on other sites More sharing options...
Leadwing Posted October 19, 2007 Author Share Posted October 19, 2007 Great fankooooooooooo Quote Link to comment 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.