Jump to content

Passing variables to more than one PHP


low-rider

Recommended Posts

hi,

 

im working on creating an online shopping website and wanna know if i can pass the same variable to more than one php?

 

for example when the user selects products(products.php), they get printed on the next page where they select delivery type and address(checkout.php), after that i need to pass the same variable to the overview page where the user can see what he/she have ordered, where it is being dispatched to, the cost and the payment details!!

 

im using $_GET['my var'] method at the moment and have action="checkout.php" in my products.php!

 

and finally i want to do a client side check on whether any items have  been selected when the user clicks on "continue button".

 

thank you very much!

 

 

Link to comment
https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/
Share on other sites

The best use of passing these variables I've seen is in use by osCommerce.  The variables for each module are kept in one file and called when needed.  You can use $global if your server allows it.

 

It seems that it would be best to register the sessionID and contain the products within a variable specifically assigned to that sessionID called from a main page with all of your cart variables.

i solved the first problem with using $_SESSION, so thanks very much for that!

 

another problem i have is when the user selects products! this is done by a checkbox and the quantitiy is done by a text box!

 

now, whenever "contuinue" button is clicked the user is take to the checkout page....what i want to is to u deny him access to the checkout until he has selected an item!!!

 

i want this to be done at the client level not server!! can any one help me???

thanks

can someone confirm that i have done this correctly??

 

in my products.php i have got this...

 

session_start();

$_SESSION['BagName'] = $BagName;

$_SESSION['BallName'] = $BallName;

$_SESSION['HatName'] = $HatName;

$_SESSION['QBag'] = $QBag;

$_SESSION['QHat'] = $QHat;

$_SESSION['QBall'] = $QBall;

 

 

and in my overview i have this.....

 

session_start();

 

$BagName = $_SESSION["BagName"];

$BallName = $_SESSION["BallName"];

$HatName = $_SESSION['HatName'];

$QHat = $_SESSION['QHat'];

$QBag = $_SESSION['QBag'];

$QBall = $_SESSION['QBall'];

 

 

but when i try to echo something in overview it doesnt print!

 

what am i doing wrong?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.