programguru Posted February 4, 2009 Share Posted February 4, 2009 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? Link to comment https://forums.phpfreaks.com/topic/143812-solved-using-session-to-carry-variable-value-to-next-page-wout-submit-form-button/ Share on other sites More sharing options...
Maq Posted February 4, 2009 Share Posted February 4, 2009 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']; Link to comment https://forums.phpfreaks.com/topic/143812-solved-using-session-to-carry-variable-value-to-next-page-wout-submit-form-button/#findComment-754609 Share on other sites More sharing options...
programguru Posted February 4, 2009 Author Share Posted February 4, 2009 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']; Link to comment https://forums.phpfreaks.com/topic/143812-solved-using-session-to-carry-variable-value-to-next-page-wout-submit-form-button/#findComment-754612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.