Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 10:58 AM
quinonez@gmail.com
Guest
 
Posts: n/a
Default PHP FORMS and $_SESSIONS

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

  #2  
Old July 17th, 2005, 10:58 AM
Jan Pieter Kunst
Guest
 
Posts: n/a
Default 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" = @.
  #3  
Old July 17th, 2005, 10:58 AM
Quinonez
Guest
 
Posts: n/a
Default Re: PHP FORMS and $_SESSIONS

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

  #4  
Old July 17th, 2005, 10:58 AM
Chung Leong
Guest
 
Posts: n/a
Default 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;


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles