This is a discussion on PHP FORMS and $_SESSIONS within the PHP Language forums, part of the PHP Programming Forums category; i have a 7 page form and many many many variables.. i cant figure out how to get the variables ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
i have a 7 page form and many many many variables..
i cant figure out how to get the variables to move from each page and show after it is submitted. I can get the last page of the form to show on the action page but not any of the other pages before that. Should i be entering every single variable from each page into a $_SESSION['varname'] or is there an easy way to do it.. the script i am using on the action page is: <? foreach ($_POST as $_SESSION['field'] => $value) { echo "$field: $value<br>"; } ?> and that works for the last page of the form but not anyother? please help Thanks |
|
|||
|
quinonez@gmail.com wrote:
> i have a 7 page form and many many many variables.. > i cant figure out how to get the variables to move from each page and > show after it is submitted. I can get the last page of the form to show > on the action page but not any of the other pages before that. > > Should i be entering every single variable from each page into a > $_SESSION['varname'] That's a possibility. You could also echo all variables from the previous page in hidden fields in the next page, like this: foreach ($_POST as $varname => $value) { $value = function_you_should_write_to_escape_value($value); echo "<input type=\"hidden\" name=\"$varname\" value=\"$value\" /> "; } Note that you can't have variables with the same name on different pages if you use this technique. HTH, JP -- Sorry, <devnull@cauce.org> is een "spam trap". E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @. |
|
|||
|
<quinonez@gmail.com> wrote in message
news:1102780589.525949.105070@z14g2000cwz.googlegr oups.com... > i have a 7 page form and many many many variables.. > i cant figure out how to get the variables to move from each page and > show after it is submitted. I can get the last page of the form to show > on the action page but not any of the other pages before that. > > Should i be entering every single variable from each page into a > $_SESSION['varname'] > > or is there an easy way to do it.. > the script i am using on the action page is: > > <? > foreach ($_POST as $_SESSION['field'] => $value) > { > echo "$field: $value<br>"; > } > ?> > > and that works for the last page of the form but not anyother? > please help The more orthodox approach is to use hidden form fields. The easiest way to do this is to save the $_POST array of each submit in $_SESSION. form1.php: $_SESSION['form1'] = $_POST; form2.php: $_SESSION['form2'] = $_POST; |