Omzy Posted August 26, 2009 Share Posted August 26, 2009 I'm just in the process of building a multi part/page form. I have been advised to use SESSIONS, however I'm struggling to think of the benefits of using sessions to pass data when everything is being passed via $_POST anyway. Can someone shed some light on this? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/ Share on other sites More sharing options...
Omzy Posted August 27, 2009 Author Share Posted August 27, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907506 Share on other sites More sharing options...
gaza165 Posted August 27, 2009 Share Posted August 27, 2009 SESSIONS keep the data stored all the time the session is open and therefor the session data can be used anywhere on the website until the session is destroyed or the session variables are 'unset'. What are you trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907509 Share on other sites More sharing options...
Omzy Posted August 27, 2009 Author Share Posted August 27, 2009 Well it's just a basic multi part form. I've managed to create it so that data is being passed via $_POST as the form progresses. At the last stage the form data is sent via email to me. The form data doesn't need to be used anywhere else on the site, so I dnt think I need to use sessions? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907515 Share on other sites More sharing options...
gaza165 Posted August 27, 2009 Share Posted August 27, 2009 Well sessions would be a good idea.... as each stage of the form process goes forward you can store all the data into the sessions instead of passing the data from the previous stages to the very end each time. Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907520 Share on other sites More sharing options...
Omzy Posted August 27, 2009 Author Share Posted August 27, 2009 So you mean to say I can eliminate the use of hidden variables by using sessions? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907532 Share on other sites More sharing options...
gaza165 Posted August 27, 2009 Share Posted August 27, 2009 no, you will still need to use hidden inputs to pass the data but as soon as you have passed the $_POST data you can save it in SESSIONS instead of keep posting the same data over and over again until you reach the last stage of the form process. If you store the data in sessions once you have passed it, you have it stored continually without having to re-post the data to the last step. do you see what i mean?? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907537 Share on other sites More sharing options...
Omzy Posted August 27, 2009 Author Share Posted August 27, 2009 OK basically there are 4 parts on this form - parts 1-3 capture the data and part 4 is the confirmation page and where the email gets sent. At the moment I use $_POST to pass the data for each part of the form, so on parts 2 and 3 I still have to pass forward the data for part 1 using hidden variables. Am I right in understanding if I use sessions I only have to pass this data "once"? Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-907548 Share on other sites More sharing options...
Omzy Posted August 28, 2009 Author Share Posted August 28, 2009 Bump Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-908336 Share on other sites More sharing options...
lynxus Posted August 28, 2009 Share Posted August 28, 2009 yeah , if you use sessions from part 2 onwards you dont need to pass hidden vars. So on page 2, when it gets its data from $_POST['name']; ratherthan putting that data in vars, you put it into a session, so later on the rother pages just read from those sessions rather than doing another $_POST ie: on page 2: $_SESSION['username'] = $_POST['username']; Then later on to use the username data, rather than putting it in a hidden field and posting again, your other scripts just call $_SESSION['username']; to get the data. Also remember when using session to put this at the VERY top of your php session_start(); Thanks G Quote Link to comment https://forums.phpfreaks.com/topic/172038-multi-part-from/#findComment-908339 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.