PHP HTTP POST Question. How do you pass data from multiple forms as an HTTP message?

I have page 1 and page 2. I want to take information from page 1 of the step, then to page 2 and save it as session information (which I already did). As soon as this information is collected, I will want to send it to another php page using HTTP POST.

+4
source share
2 answers

If you want to send data using POST , you will need to bring these variables as hidden input fields in your form before your users click the submit button:

 <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 can simply reference $_SESSION when you are at the processing stage, if applicable.

+5
source

As ILMV said, on subsequent pages you can copy previous pages into hidden fields.

Alternatively, if dividing your form into pages is a constructive solution, and not a technical one, you can output the entire form at a time, and then use javascript to display only a certain number of elements at a time.

+3
source

Source: https://habr.com/ru/post/1308214/


All Articles