jcstanley Posted May 4, 2007 Share Posted May 4, 2007 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 More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 <link rel="stylesheet" type="text/css" href="<?php echo (!$_COOKIE[style])?'default':$_COOKIE[style];?>.css" /> Link to comment https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/#findComment-245450 Share on other sites More sharing options...
jcstanley Posted May 4, 2007 Author Share Posted May 4, 2007 still not working. I don't think a cookie is being created. Link to comment https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/#findComment-245466 Share on other sites More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 $_GET[choice] Link to comment https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/#findComment-245519 Share on other sites More sharing options...
jcstanley Posted May 4, 2007 Author Share Posted May 4, 2007 $_GET[choice] i added that to the changestyle.php script but still no change Link to comment https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/#findComment-245570 Share on other sites More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 <?php $Year =31536000 + time(); setcookie ('style', $_GET[choice], $Year); header("Location: $HTTP_REFERER"); ?> Link to comment https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/#findComment-245578 Share on other sites More sharing options...
rcorlew Posted May 4, 2007 Share Posted May 4, 2007 Ok try changing this: <?php echo (!$style)?'default':$style ?> To this: if($_COOKIE[style] == null) {$style="blue";} if($_COOKIE[style] != null) {$style="$_COOKIE[style]";} <?php echo "$style" ?> Link to comment https://forums.phpfreaks.com/topic/50006-stylesheet-switcher-not-working/#findComment-245607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.