Click to See Complete Forum and Search --> : $_get


AnotherMuggle
12-28-2007, 10:32 AM
I am relatively new to PHP programming and struggling with the basics...hopefully someone will be kind enough to help me out here.

I have a number of pages that contain buttons, which are effectively options for the user. When a button is pressed it moves the user to the next page, but it is required that the button that was pressed is remembered.

I have one page that asks the user to press the button (ADULT, CHILD, SPECIAL). They press the button and are taken to the next page which asks for the type of ticket they would like to purchase (SINGLE, RETURN, ALLDAY). Next the user will be taken to the final page where their selected options are shown to them to confirm.

I have managed to use $_GET to pass a variable from one page to the following page. Is it possible to pass this value to all consecutive pages so that I have all of the button choices available at the summary page.

Hope that makes sense :S

Thanks,
Tom

scragar
12-28-2007, 10:40 AM
you have 2 choices, use cookies to store the options at each page, or create hidden form elements for each passed value to also pass the value of all previous options.

AnotherMuggle
12-28-2007, 10:43 AM
...create hidden form elements for each passed value to also pass the value of all previous options.
Thanks, how would I go about this later method.

Are you able to provide some sample code to demonstrate how to do this?

andkhl
12-28-2007, 10:44 AM
I would say, use COOKIE to store all that info about your user in one place. Then when the info is not needed anymore, you will destroy the cookie.

P.S. Sorry, I din't notice the post above.... :o

scragar
12-28-2007, 10:45 AM
you can use a quick foreach to write them all for you:
foreach($_GET as $key =< $val){
echo "<input type='hidden' name='$key' value='$val'>";
};

AnotherMuggle
12-28-2007, 10:49 AM
Thanks guys.

I think I should just take my time and learn how to use a COOKIE.

Huevoos
12-28-2007, 11:29 AM
I'd suggest using sessions.
Page 1:

session_start();
$_SESSION['type'] = "child";


Page 2:

session_start();
echo $_SESSION['type']; //child

AnotherMuggle
12-28-2007, 03:42 PM
I'd suggest using sessions.
Page 1:

session_start();
$_SESSION['type'] = "child";


Page 2:

session_start();
echo $_SESSION['type']; //child


Used this solution in the end, works a treat.
Thanks for everyone's input.