Post variables to another php page inside a function

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
purephazer3
Forum Newbie
Posts: 6
Joined: Thu Mar 16, 2006 3:23 pm

Post variables to another php page inside a function

Post by purephazer3 »

Ok, I am totally new at this so don't throw any stones.

I have a form with lots of drop down selection boxes. Let's say these variables are $A, $B and $C. The form submit button POSTS the variables to SELF. I need to create a function ("additem") that will combine the variables $A, $B and $C into variable $D. Then POST those variables to another php page, let's call it cart.php.

Code: Select all

function additem($A, $B, $C){
 $D = $A + $B + $C;
//now how do i post $D to cart.php and leave this page
}
purephazer3
Forum Newbie
Posts: 6
Joined: Thu Mar 16, 2006 3:23 pm

Post by purephazer3 »

alright, I think Instead of combining these variables within the form page and posting to SELF. I am going to post the variables to the cart.php page and create a function within that will combine the variables and add them to the cart.

Is that a better solution?

Logically, I would have preferred combining the variables inside of the form page then sending out, because if I keep adding forms I am going to have to change the coding on the cart.php page everytime.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

on cart.php simply have

Code: Select all

//this can be included or hardcoded right in the file
function additem($A, $B, $C){
   return ($A + $B + $C);
}

$added = addItem(..);

echo $added;
Post Reply