View Full Version : passing values

03-20-2004, 02:52 PM
hi all,
ok this might be a simple question but i still am not really sure. ok here it goes, i have 4 forms. lets name is pg1.php, pg2.php,pg3.php,pg4.php.
pg1.php is where all the users fill up their particulars and then this will go to pg2.php. in pg2.php, the will choose their options like designs or music or whatever. then pg2.php will go to pg3.php to make their final selections of what they have selected from pg2.php. then this leads to the last page, pg4.php and this page is where all the data that the user has picked from pg1.php to pg3.php will go inside.
now the question. from pg1.php, how do i pass the values that the user has filled in and carry it till the last page(pg4.php) and insert it into the database? understand what i am trying to do here? i mean...to be exact, how do i pass all the values that the user has chosen/filled from pg1.php to pg3.php and insert it all into the database in pg4.php?
pls help..much appreaciated.thanking u in advance.

03-20-2004, 03:05 PM
If you make use of hidden form values, this can be done quite easily. Example of pg1.php:

<form action="pg2.php" method="post">
Name: <input type="text" name="Name" />
Email: <input type="text" name="Email" />
<input type="submit" value="Submit" />

Then for pg2.php, use some PHP:

<form action="pg3.php" method="post">
<input type="hidden" name="Name" value="<?php echo $_POST['Name']; ?>" />
<input type="hidden" name="Email" value="<?php echo $_POST['Email']; ?>" />
Country: <input type="text" name="Country" />
..... And so on
<input type="submit" value="Submit" />

Notice how I set the action to "post", so I can access the $_POST[] array on subsequent pages. The information that pg2.php would send in the example above is:

$_POST['Name'] = value of "Name" input
$_POST['Email'] = value of "Email" input
$_POST['Country'] = value of "Country" input

03-20-2004, 03:20 PM
Or you can pass them by sessions

03-20-2004, 04:52 PM
thanks for the reply so quick.:). but what u told me is what i know. the thing is...how do u carry those values from pg1.php right up to pg4.php?do i have to keep using :

<input type="hidden" name="Name" value="<?php echo $_POST['Name']; ?>" />

till the end?this is what i meant. i know how to pass values between 2-3 pages...how about 4 and so on?do i have to put

<input type="hidden" name="Name" value="<?php echo $_POST['Name']; ?>" />

in pg2.php, pg3.php and pg4.php? or just only one time?which is what u demonstrate?pls advice

03-20-2004, 05:45 PM
You would need to put that on all the pages you wanted the information to be passed from.

Or you could go with nightfire and use sessions.