Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey Guys,
I've got a page with a drop down menu on where I need to collect a users selection, this then clicks through to another page where I grab users contact details - this page doesn't require the previous selection. It then clicks through to another page where I DO require the selection from the drop down menu - two pages on effectively.
So my problem is.... I need to carry a variable over two pages, anyone have any ideas how I can do this?
Thanks,
AJ

-Use a session variable.
-Use cookies.
-You could also just create a hidden form filed on the second page, and set it's value equal to the value in page one. Then when the second page is submitted, you can get the value from the hidden form field.
-Ryan Adams
Free Computer Tips and more:http://RyanTAdams.comPaid Tech Support: Black Diamond

Excellent! Thanks for that Ryan Adams :)
Unfortunately, I can't get the session to work.... its started, then on the second page I grab the variable from the session and make sure its working with...
$borderselection = $_SESSION['borderselection'];
echo $borderselection;This works, no problem
so I tried chucking it back in the session (just to make sure its there) with the extra line:
$_SESSION['borderselection'] = $borderselection;
then on the third page I try and grab it again with
$borderselection = $_SESSION['borderselection'];
echo $borderselection;but no luck :( Any ideas?
I tried the textbox idea - this works great, but I'm working with an array unfortunately... and I'm pretty sure you can't get a textbox to handle that? It just sees the data as plain text - 'array'.

You don't need to "chuck it back in the session". Try just getting the session variable on the third page. Do it give you an error, or just not return a value?
I had a typo in my previous post, i meant to suggest you use a hidden form field. For example, if the data gets passed to page 2in the variable $_POST["array"], just include this on page two:
<input type="hidden" name="hideme" value="<? echo $POST["array"] ?>" />
That will then pass the same data onto page three as $_POST["hideme"].
PS: If you are using session variables, you will need to make sure the session is active on each page and that each page is accessed via the same domain.-Ryan Adams
Free Computer Tips and more:http://RyanTAdams.comPaid Tech Support: Black Diamond

Hey,
I'm not getting any errors, just no values. Also the session is active on each page, all pages actually drawing from the same header where the session is declared active.
Your text box workaround is working fine, though not with an array. It loses the array as soon as it hits the textbox, instead opting for the plain text 'Array'. :(

If you've got an array, then you could probably use implode
echo "<input name=\"myarray\" value=\"" . implode(":", $array) . "\" type=\"hidden\">";or depending on scope, possibly
<input name="myarray" value="<?php echo implode(":", $array);?>" type="hidden">

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |