Passing PHP variables and form variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
merlinti
Forum Newbie
Posts: 13
Joined: Mon Aug 19, 2002 1:24 pm
Contact:

Passing PHP variables and form variables

Post 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.
Jay
Forum Newbie
Posts: 22
Joined: Fri Jul 12, 2002 8:36 am
Location: KUL, Malaysia

Post 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?
merlinti
Forum Newbie
Posts: 13
Joined: Mon Aug 19, 2002 1:24 pm
Contact:

Post 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
merlinti
Forum Newbie
Posts: 13
Joined: Mon Aug 19, 2002 1:24 pm
Contact:

Post 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:
Post Reply