Jump to content

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


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'];

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.