passing 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
username10
Forum Newbie
Posts: 5
Joined: Tue Nov 11, 2003 11:40 am

passing variables

Post by username10 »

Please help.

I have a quote form (javascript and php). When the user submit the information, they are returned a calculated quote.

If the user agrees, they would then click a purchase button.

I need to carry that quote on to "2checkout" (a shopping cart), and am lost on the approach.

Please help.


Al
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Assuming (which is a dangerous thing) that the user would be able to continue to shop you may want to consider storing their order in a database table. That way you could go and get it/them when you need to.
John M
username10
Forum Newbie
Posts: 5
Joined: Tue Nov 11, 2003 11:40 am

Post by username10 »

like your sig,

.....

The does sound like the most ideal However, not in a position to do it. Is it possible to just retain the quote variable & value from the first form and place it in a new form on the parsed php file.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Are you using sessions? If so, set it as a session var and you will have it any page through out the session. If not, set a var equal to the POST (or get depending on which you use) var.

John M

P.S. You like the steel-your-face huh, LOL. Most people on this forum have no idea what it means. But that is okay I guess... more music for me!
username10
Forum Newbie
Posts: 5
Joined: Tue Nov 11, 2003 11:40 am

Post by username10 »

I'll read up on setting a variable to post.



......GD logo
http://charmcreations.com/Products/inde ... l/2965.htm
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

If you are using the POST method then it is already there on the second page so on the second page set the var to the POST value. Sessions would be worth looking into.

Code: Select all

<?php
$var = $_POST['varName']
?>

John M
Last edited by Johnm on Tue Nov 11, 2003 2:04 pm, edited 2 times in total.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

Johnm wrote:If you are using the POST method then it is already there on the second page so on the second page set the var to the POST value. Sessions would be worth looking into.

Code: Select all

<?php
var = $_POST['varName']
?>

John M
You mean

Code: Select all

<?php
$var = $_POST['varName']
?>
, right?
?>
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Uhhh.... What do you mean?

[ John quickly makes use of his powers as a moderator to go and change his post to reflect the correct syntax]


It is right... Now

LOL
I have been writing VB for the last two weeks... Sorry.


John M
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

There is a PHP Shopping cart tutorial that might help you

http://www.macromedia.com/devnet/mx/dre ... _cart.html
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Johnm wrote:If you are using the POST method then it is already there on the second page so on the second page set the var to the POST value. Sessions would be worth looking into.

Code: Select all

<?php
$var = _POST['varName']
?>

John M
haha its still not right :D

Code: Select all

<?php
$var = $_POST['varName']
?>
:lol:
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

LOL... Yes it is... Look!

[John again takes his mod powers out of the box]
[Hahah... Must note that there is a preview function on this board ;) -- JAM]

See! LOL


Sorry About that. Too many programming languages running around in my head.
username10
Forum Newbie
Posts: 5
Joined: Tue Nov 11, 2003 11:40 am

Post by username10 »

It's hard being new, but this is what I did. Yes , it's not right. need more help. I'm trying to get the totalcharge value into the total value of the new form.

<form method="post" action="..." name="form">
<?php
$total = $_POST['totalcharge']
?>

<p>Total Purchase
<input type="text" name="total" value=$total>
</p>
<p>
<input type="hidden" name="sid" value="123">
<input type="hidden" name="cart_order_id" value="quote">
<input type="hidden" name="demo" value="y">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

Thanks

JR
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

You'll need to change this
<input type="text" name="total" value=$total>
to this
<input type="text" name="total" value="<?php echo $total ?>">
Then it should work
username10
Forum Newbie
Posts: 5
Joined: Tue Nov 11, 2003 11:40 am

Post by username10 »

Thank you all, this worked perfectly. I will read up on sessions tonight.

Thanks again!
Post Reply