Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Session Variables

Status
Not open for further replies.

jmg498

Technical User
Oct 31, 2007
26
US
Thanks to the user that suggested I use session variables. Unfortunately, I am having some trouble with those as well.

I currently have a webform where the user enters the location of where they want to view the weather information from. Then, I use POST in PHP like this:

post.php script:

<?php
session_start();
echo $_POST["location"];
session_register("location");
require("table.php");
?>

Then, table.php creates an image and then calls another script rdrcfg.php...and within this script, I do the following:

$radar = $location;

Because other parts of this particular script are already set to use $radar. But it doesn't seem to pass the $location variable from the initial post.php script to the rdrcfg.php script. It does seem to go to the table.php script, because I printed it out and it appears.

Any suggestions?

Thanks so much!!!
 
***DISREGARD****

Figured it out! Thanks!
 
You really could have kept this in the same thread.

Anyway, to your question, you are creating a session var named location, however there is no actual variable with that name. The variable you get from the form is $_POST['location'] Also you should use the $_SESSIONS super global, as session_register is now deprecated.

Something like this should work:

Code:
session_start();
$_SESSIONS['location']=$_POST['location'];

Then in you other script:
Code:
session_start();
$radar=$_SESSION['location'];








----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top