snow Posted September 12, 2007 Share Posted September 12, 2007 Hi can someone simply explain how I can use hidden form elements so I can keep variables for later on. For example: Web Page 1 (Has the forms) --> Web Page 2 (gets $_POST) --> Web Page 3 now has lost all the post data from page 2, how do I keep it so I can re-use it? I'm new at php and any help would be appreciated, preferrably simple methods! Thanks heaps in advance! Quote Link to comment https://forums.phpfreaks.com/topic/69032-solved-hidden-form-elements/ Share on other sites More sharing options...
micah1701 Posted September 12, 2007 Share Posted September 12, 2007 use sessions put: session_start(); at the top of each page. then you can pass variables from page to page in your code by assigning them to the session array. page 1: <?php session_start(); $_SESSION['var1'] = "some data"; ?> page2 or 3 or 4 or whenver you want as long as the person keeps there browser open and comes back to your site: <?php session_start(); echo $_SESSION['var1']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/69032-solved-hidden-form-elements/#findComment-347019 Share on other sites More sharing options...
snow Posted September 12, 2007 Author Share Posted September 12, 2007 Thank you. But does this work for forms? Should I do this on the post page of the form: $_SESSION['day'] = $_POST['day']; $_SESSION['time'] = $_POST['time']; $_SESSION['delivery'] = $_POST['delivery']; Quote Link to comment https://forums.phpfreaks.com/topic/69032-solved-hidden-form-elements/#findComment-347031 Share on other sites More sharing options...
snow Posted September 12, 2007 Author Share Posted September 12, 2007 Oh I got it working, thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/69032-solved-hidden-form-elements/#findComment-347032 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.