I am trying to pass on some variables using SESSION from one PHP page to the next.
The first page contains this code and after the user clicks submit, it goes to Page 2:
Make sure that you are starting your session before creating the variables and before calling them back :
session_start();
Are you sure your variables are set i.e. $totalcost? A comment on your code. Unless, you are breaking in and out of PHP and HTML, you do not need to open and close PHP on every line.
This can be rewritten:
<!--SESSIONS TO PASS ON VARIABLES-->
<?php $_SESSION['file'] = $file; ?>
<?php $_SESSION['linecount'] = $linecount; ?>
<?php $_SESSION['priceperpost'] = $priceperpost; ?>
<?php $_SESSION['totalcost'] = $totalcost; ?>
<!--//SESSIONS TO PASS ON VARIABLES-->
As:
<?php
// SESSIONS TO PASS ON VARIABLES
session_start();
$_SESSION['file'] = $file;
$_SESSION['linecount'] = $linecount;
$_SESSION['priceperpost'] = $priceperpost;
$_SESSION['totalcost'] = $totalcost;
// SESSIONS TO PASS ON VARIABLES
?>