Helpful Information
 
 
Category: PHP Development
Passing Variables

Is there an easy way to pass varibles from one page to the next?
1. I have a form (index.shtml) where you enter data

2. Then when the preview button is clicked it runs a script (order.php3)that queries the database for more details and displays both the form data and data from the database.

3. When you click the confirm button it runs a script (order_confirm.php3) which grabs certain varibles and email/posts to database.

The problem I'm having is getting a hold of these varibles that reside in the order.php3 script and properly referring to them in my order_confirm.php3

Any ideas would be appreciated
cheers
Tom K

Hi,
In your order.php3, i figure you have a form.
(because of the submit-button)
well, let's say you have some variables in order.php3, you want to use in order_confirm.php3. What you do, is write the names and values of these vars in the form, by using 'hidden fields':
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<?
$name;
$foo_array;

echo "<FORM METHOD=POST ACTION=order_confirm.php3>n";
echo "<INPUT TYPE=hidden NAME="name" VALUE="$name">n";
echo "<INPUT TYPE=hidden NAME="foo_array[]" VALUE="$foo_array[0]">n";
echo "<INPUT TYPE=hidden NAME="foo_array[]" VALUE="$foo_array[1]">n";
echo "<INPUT TYPE=hidden NAME="foo_array[]" VALUE="$foo_array[2]">n";
* and here some mroe form-tags *
echo "</FORM>n"
[/code]
Of course, you'd better write a small function that walks through an array and for each element, prints a hidden form-field (instead of these 0, 1, and 2 up here), but i think you can figure that iout yourself.

Hope, this helps you.

Greetz,
EyE

------------------
--
<WARNING: signature has NULL-value>










privacy (GDPR)