Jump to content

Stylesheet switcher not working


jcstanley

Recommended Posts

Hi

 

I am new to the whole idea of stylesheets so thought I would give them a try.

 

What I am trying to do is provide different colour schemes (only 2 at the moment, blue - default.css and orange - orange.css) which the user can select.

 

I have read numerous tutorials but can't get any of them working.  The one used below is from about.com:

 

The head section of the index.htm page is as follows:

 

<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="<?php echo (!$style)?'default':$style ?>.css" /> 

</head>

 

The links for the different styles are as follows:

 

<a href="changestyle.php?choice=orange"> Orange</a> | <a href="changestyle.php?choice=Blue"> Blue</a>

 

and the changestyle.php script:

<?php 
$Year =31536000 + time();
setcookie ('style', $choice, $year);
header("Location: $HTTP_REFERER"); 
?>

 

All seems quite straight forward but when the index.htm page is views the default.css (blue) style has not been applied.  When you click on a link to change it to Orange for example, the page reloads but there is no change in appearance.

 

Any ideas what could be wrong?

 

Many thanks

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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