4

I have a step 1 page, and a step 2 page. I want to take the information from step 1 page, then step 2 page, and save as session information (which i have already done). Once this information is all gathered i then want to be able to submit it to another php page using HTTP POST.

2 Answers 2

5

If you want to send the data using POST you'll need to bring those variables down as hidden input fields on your form before your users clicks submit:

<input type="hidden" name="firstname" value="<?php echo($_SESSION['firstname']); ?>" />
<input type="hidden" name="surname" value="<?php echo($_SESSION['surname']); ?>" />
<input type="hidden" name="age" value="<?php echo($_SESSION['age']); ?>" />

Alternatively you could just reference the $_SESSION when your at the processing stage, if this is applicable.

Sign up to request clarification or add additional context in comments.

2 Comments

*what if its information that can't be seen like a userid number or something like that? i just thought about that issue
If the item exists within the session you will be able to render it in your HTML, alternatively you can access the session directly on your processing page.
3

As ILMV said, on subsequent pages you can copy the previous page's details into hidden fields.

Alternatively, if splitting your form into pages is a design decision rather than a technical one, you could output the whole form in one go and then use javascript to show only a certain number of elements at a time.

3 Comments

<input type="hidden" name="requested_amount" value="<? echo $_SESSION['requested_amount'] ?>" /> <input type="hidden" name="first_name" value="<? echo $_SESSION['first_name'] ?>" /> <input type="hidden" name="last_name" value="<? echo $_SESSION['last_name'] ?>" /> had to use echo.... but yes good call i'll just use that for now.
This "certain number of elements" at a time trick is actually pretty good, it degrades nicely if JavaScript is disabled and solves the problem.
what if its information that can't be seen like a userid number or something like that? i just thought about that issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.