title: Passing PHP Variable From One Dynamic Page to Another
body: <p>I am trying to pass on some variables using SESSION from one PHP page to the next.</p>
  
  <p>The first page contains this code and after the user clicks submit, it goes to Page 2:</p>
  
  <pre><code>&lt;!--SESSIONS TO PASS ON VARIABLES--&gt;
  &lt;?php $_SESSION['file'] = $file; ?&gt;
  &lt;?php $_SESSION['linecount'] = $linecount; ?&gt;
  &lt;?php $_SESSION['priceperpost'] = $priceperpost; ?&gt;
  &lt;?php $_SESSION['totalcost'] = $totalcost; ?&gt;
  &lt;!--//SESSIONS TO PASS ON VARIABLES--&gt;
  </code></pre>
  
  <p>And this is what I have on the next page, Page 2, after the form is submitted:</p>
  
  <pre><code>&lt;!--VARIABLES FROM PREVIOUS PAGE--&gt;
  &lt;?php $file = $_SESSION['file']; ?&gt;
  &lt;?php $linecount = $_SESSION['linecount']; ?&gt;
  &lt;?php $priceperpost = $_SESSION['priceperpost']; ?&gt;
  &lt;?php $totalcost = $_SESSION['totalcost']; ?&gt;
  &lt;!--//VARIABLES FROM PREVIOUS PAGE--&gt;  
  </code></pre>
  
  <p>But it is not getting the code because I am trying to echo the variables on Page 2:</p>
  
  <pre><code>  &lt;u&gt;Number of Posts:&lt;/u&gt; &lt;?php echo ($linecount); ?&gt;&lt;br&gt;
    &lt;br&gt;
    &lt;u&gt;Price Per Post:&lt;/u&gt; $&lt;?php echo ($priceperpost); ?&gt; &lt;br&gt;
    &lt;u&gt;Total Cost:&lt;/u&gt; $&lt;?php echo ($totalcost); ?&gt;&lt;br&gt;
    &lt;br&gt;
  </code></pre>
  
  <p>Please help as I do not know what I am doing wrong, any help would be greatly appreciated.</p>
  
  <p>Yes I have also called session_start</p>
  
  <p>Here is the updated code:</p>
  
  <pre><code> &lt;?php 
  session_start(); 
  $_SESSION['file'] = $file;
  $_SESSION['linecount'] = $linecount;
  $_SESSION['priceperpost'] = $priceperpost;
  $_SESSION['totalcost'] = $totalcost; 
  ?&gt;
  </code></pre>
  
  <p>and on the next page</p>
  
  <pre><code>&lt;?php
  session_start();
  $file = $_SESSION['file'];
  $linecount = $_SESSION['linecount'];
  $priceperpost = $_SESSION['priceperpost'];
  $totalcost = $_SESSION['totalcost']; 
  ?&gt;
  </code></pre>