I have 3 files.
top.php
index.php
bottom.php
The index.php (content) uses includes to build the pages (top/bottom).
Now, in top.php I have the following code:
Code:
Code: Select all
<?php
session_start();
$_SESSION["css"] = ($_GET['css']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>carraigeridge.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="keywords" lang="en" content="" />
<meta name="description" lang="en" content="" />
<meta name="copyright" content="" />
<meta name="robots" content="all" />
<script type="text/javascript" src="/_scripts/lightbox/prototype.js"></script>
<script type="text/javascript" src="/_scripts/lightbox/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="/_scripts/lightbox/lightbox.js"></script>
<script type="text/javascript" src="/_scripts/external.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="/_stylesheets/lightbox.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/_stylesheets/screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="/_stylesheets/print.css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="screen" href="/_stylesheets/screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="/_stylesheets/print-ie.css" />
<![endif]-->
<?php
$date = date("n");
if (!isset($_GET['css'])) {
if ($date >= 4 && $date <= 5 || $css == 'spring'){ ?>
<link rel="stylesheet" href="/_stylesheets/spring.css" type="text/css" media="screen" />
<? } elseif ($date >= 6 && $date <= 8 || $css == 'summer') { ?>
<link rel="stylesheet" href="/_stylesheets/summer.css" type="text/css" media="screen" />
<? } elseif ($date >= 9 && $date <= 10 || $css == 'autumn') { ?>
<link rel="stylesheet" href="/_stylesheets/autumn.css" type="text/css" media="screen" />
<? } elseif ($date >= 11 && $date <= 3 || $css == 'winter') { ?>
<link rel="stylesheet" href="/_stylesheets/winter.css" type="text/css" media="screen" />
<? } else { ?>
<link rel="stylesheet" href="/_stylesheets/screen.css" type="text/css" media="screen" />
<? };
} else { ?>
<link rel="stylesheet" href="/_stylesheets/<?php echo $_GET['css']; ?>.css" type="text/css" media="screen" />
<? }; ?>
</head>
<body>
<div id="wrapper">
<div id="wrapper-content">
<div id="header">
<div class="header-h"></div>
<ul class="seasons">
<li><a href="?css=spring" title="Spring">Spring</a></li>
<li><a href="?css=summer" title="Summer">Summer</a></li>
<li><a href="?css=autumn" title="Autumn">Autumn</a></li>
<li><a href="?css=winter" title="Winter">Winter</a></li>
</ul>In the index file I have the following code:
Code:
Code: Select all
<?PHP
session_start();
print $_SESSION['css'];
$section='community';
include('../_includes/top.php');
?>
<div id="content">
<div id="content-wrapper">
<div id="content-info">
<div id="content-title"><h1>Engage, Inspire...</h1></div>
<div id="content-image-community"><span>Community Image</span></div>
</div>
<div id="content-links"><?php include("links.php"); ?></div>
<div id="content-links-external">
<ul class="content-links">
<li></li>
</ul>
</div>
</div>
</div>
<?PHP
include('../_includes/bottom.php');
?>and the bottom.php simply finishes the page.
If you take a look at the top.php file you'll see that I have some PHP that loads a CSS file based on either the date, or the variable set by the user.
Below that in the same file you see some links that send variables such as "?css=spring".
The goal, is for the site to load the appropriate css file based on the season, but override that if the user clicks one of the season links and stay that way until the user closes the page.
What is happening is that the date is working, and the links are working, but what happens is when I am on a page, and I click "Autumn" for example, it will change the css file to autumn for that page, but if I then go to another page of the site, the css file defaults back to the date.
At first I thought the variable was getting lost, but it turns out after adding the "print $_SESSION['css'];" code, it seems to be actually passing the variable to the next page without problem....it SEEMS!
So what seems to be happening is that while the variable is getting passed, the code checking the variables to override the date isn't seeing it, and it's defaulting back. Can anyone look over my code and see if they can get why it's not passing the variable to the correct place, as well as making sure all my code is correct.
Thanks,
Jeff