Jump to content

Multi Part From


Omzy

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

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"?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.