Page 1 of 1

Post variables to another php page inside a function

Posted: Mon Mar 20, 2006 9:33 am
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
}

Posted: Mon Mar 20, 2006 10:10 am
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.

Posted: Mon Mar 20, 2006 10:12 am
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;