Jump to content

[SOLVED] using session to carry variable value to next page w/out SUBMIT form button


programguru

Recommended Posts

Page one:

 

capturing the value of basname into the session.

 

<?
session_start();
$previous_page = basename($_SERVER['PHP_SELF']);
$_SESSION['previous_page']="previous_page";
?> 

 

Page two:

 

echoing the value of $previous_page captured in the session to test if it's carrying over.

 

echo "$previous_page";

 

im going nutso on this... and i cannot get it to work!

 

any suggestions?

These are two separate pages right?

 

page1.php

session_start();
$previous_page = basename($_SERVER['PHP_SELF']);
$_SESSION['previous_page']=$previous_page;

 

page2.php

session_start();
echo $_SESSION['previous_page'];

Dam! Missed that one.. Thanks for clearing my head! Working now, and I also had to add my '$' to 'previous_page'  (as I see you did) to get the page name to maintain in the var.

 

These are two separate pages right?

 

page1.php

<?php
session_start();
$previous_page = basename($_SERVER['PHP_SELF']);
$_SESSION['previous_page']=$previous_page;

 

page2.php

<?php
session_start();
echo $_SESSION['previous_page'];

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.