Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP FORMS and $_SESSIONS

quinonez@gmail.com
Guest
 
Posts: n/a
#1: Jul 17 '05
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


Jan Pieter Kunst
Guest
 
Posts: n/a
#2: Jul 17 '05

re: PHP FORMS and $_SESSIONS


quinonez@gmail.com wrote:[color=blue]
> 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'][/color]

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
Guest
 
Posts: n/a
#3: Jul 17 '05

re: PHP FORMS and $_SESSIONS


i keep gettin and error with that code also would like to know how to
do it through $_SESSION

Chung Leong
Guest
 
Posts: n/a
#4: Jul 17 '05

re: PHP FORMS and $_SESSIONS


<quinonez@gmail.com> wrote in message
news:1102780589.525949.105070@z14g2000cwz.googlegr oups.com...[color=blue]
> 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[/color]

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;


Closed Thread


Similar PHP bytes