anevins Posted March 28, 2011 Share Posted March 28, 2011 SOLVED I want to use a variable I defined on another page, but I don't know how. Here's the original page with the variable: cart.php $total += $qty*$row['price']; Here's the new page new page without the variable: checkout.php //I want the value $total onto this page Thanks Link to comment https://forums.phpfreaks.com/topic/231982-how-do-i-get-this-variable-to-that-page/ Share on other sites More sharing options...
kenrbnsn Posted March 28, 2011 Share Posted March 28, 2011 You need to use sessions. In all scripts where you want to use sessions, put <?php session_start(); ?> at the start of the script before any output is generated. In the original page, you need to created the session variable: <?php $_SESSION['total'] = $total; ?> On the page where you want to get that value: <?php $total = $_SESSION['total']; ?> Ken Link to comment https://forums.phpfreaks.com/topic/231982-how-do-i-get-this-variable-to-that-page/#findComment-1193399 Share on other sites More sharing options...
anevins Posted March 28, 2011 Author Share Posted March 28, 2011 Thank you Ken. Link to comment https://forums.phpfreaks.com/topic/231982-how-do-i-get-this-variable-to-that-page/#findComment-1193401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.