low-rider Posted April 3, 2007 Share Posted April 3, 2007 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 More sharing options...
phoenixx5 Posted April 3, 2007 Share Posted April 3, 2007 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. Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-220786 Share on other sites More sharing options...
trq Posted April 3, 2007 Share Posted April 3, 2007 You can either place the variables within the $_SESSION array on products.php and collect them again on checkout.php and so on, or, place the values into a hidden field and submit them to the next page. Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-220787 Share on other sites More sharing options...
low-rider Posted April 3, 2007 Author Share Posted April 3, 2007 wow! quick reply! thanks guys! ill give it a go tmrw in the morning as it sort of late now and i cant really think anoymore! :-X Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-220788 Share on other sites More sharing options...
low-rider Posted April 4, 2007 Author Share Posted April 4, 2007 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 Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-221037 Share on other sites More sharing options...
low-rider Posted April 4, 2007 Author Share Posted April 4, 2007 whatever i do i cant get any of the variables in my session to print! is it supposed to be <? echo $_SESSION['var']; ?> i really need help please!!!! Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-221082 Share on other sites More sharing options...
low-rider Posted April 4, 2007 Author Share Posted April 4, 2007 anyone??? Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-221090 Share on other sites More sharing options...
low-rider Posted April 4, 2007 Author Share Posted April 4, 2007 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? Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-221364 Share on other sites More sharing options...
davidz Posted April 4, 2007 Share Posted April 4, 2007 I like to use this to decipher $_SESSION <?php echo "<PRE>"; print_r ($_SESSION); echo "</PRE>"; ?> Put those three lines somewhere in your page and you should get a nice print out of what is in $_SESSION. Link to comment https://forums.phpfreaks.com/topic/45474-passing-variables-to-more-than-one-php/#findComment-221392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.