Page 1 of 1

Passing PHP variables and form variables

Posted: Wed Aug 21, 2002 5:39 pm
by merlinti
Hi All,

I've got a page01.asp with a form that sends variables to page02.php.
It has php code that does a query from mySQL and outputs $TotalPrice.
Under that I have a form that allows a user to input other info. such as FirstName, LastName..etc.. And a submit button to send it to a formmail.cgi , formmail.php or php mail itself or page03.php to check the info again and then submit.
I can't figure out how to pass the $TotalPrice variable and the FirstName variable together. :(

Thanks for any help.

Posted: Wed Aug 21, 2002 6:17 pm
by Jay
i may have missed something but can't u just put the $totalprice as a hidden value in the 2nd form? or even in a session?

Posted: Wed Aug 21, 2002 6:30 pm
by merlinti
Hi,

This is what I have on hotel001.php:


<?
if ($BeenSubmitted){

print ("$Price\n<br><br>");
print ("$CheckIn");
}else{
print ("Please fill out the form first\n");
}

$Price = ("$Price");

print ("<form action=\"hotel002.php\" method=post type=\"text\">\n");
print ("FirstName <input name=\"FirstName\" type=\"text\" id=\"FirstName\">

<input type=submit name=\"Submit\" value=\"Submit\">
<input name=\"Hotel\" type=hidden id=\"Hotel\" value=\"$Price\"></form>\n");

?>


This is what I have on hotel002.php:


<?

extract($HTTP_POST_VARS);
print $Price;


print ("$Price\n<br><br>");
print ("$CheckIn");
print ("$FirstName");


?>

I' a real newbie, so alot of this code is probably wrong.

thanks

Posted: Thu Aug 22, 2002 5:28 pm
by merlinti
Hey All,

I figured that part out!

<input name="TotalPrice" type="hidden" id="TotalPrice" value="<? echo $TotalPrice ?>">

This passes the php variables to the next page.

:wink: