Jump to content

How do I get this variable to that page?


anevins

Recommended Posts

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

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

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.