Weborum Webmaster Forum > PHP session variables
Help - Search - Members - Calendar
Full Version: PHP session variables
Weborum Webmaster Forum > Web Page Design > PHP
jasonrap
I am having a bit of trouble with session variables and PHP. What I want to do is create a session variable called cam when someone first comes to the page. When cam is not set I want to load a default page within a frame called main. Then I want reload the frame main with a different page every 15 seconds, as per the value of the variable cam.

CODE

<meta http-equiv='refresh' content='15'; URL=nav.php>
<html>
<head>
</head>
<script LANGUAGE="JavaScript">
function redirect () {

<?php

session_start();
session_register ("cam");
$HTTP_SESSION_VARS ["cam"] = $cam;

print $cam;

if (isset($_GET['cam'])) {
 //checks to see if this is the first time a user has come to the site


 switch (($_GET['cam'])) {

 case "1":
 print "parent.main.location='http://google.com'";
 $cam="2";
 break;

 case "2":
 print "parent.main.location='http://ebay.com'";
 $cam="3";
 break;

 case "3":
 print "parent.main.location='http://yahoo.com'";
 $cam="1";
 break;


 default:
 print "parent.main.location='http://whatcounter.com'";
 $cam="2";
 break;

 }//end switch


 }//end if
 else
 //this is the first time they have come to the site so show default nav
 {
 print "parent.main.location='http://whatcounter.com'";
 $cam="2";
 }
?>

}

</SCRIPT>

<body ######="javascript:redirect()">



<a HREF="javascript:redirect()">Auto Cycle</a>
</body>
</html>


#####=on load

Any help would be appreciated. Thank you,
Timo
I don't have much time tonight (it's rather late and I have classes in the AM) but I quickly looked over it and...


session_start();

Needs to appear before any html hits the page... Put it as the first thing processed with the script.

-Tim

Someone else hopefully with help with the rest. biggrin.gif I've got papers up the wazoo to do this week.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.