View Full Version : Linking two css files to one page

12-14-2005, 03:30 PM
Ok. I have been searching an answer to this problem for a few days. Is it possible to let the user select which css file to apply to the wesite he is viewing? Eg. I have red.css and blue.css. How do I apply these css files to the webpage he is viewing based on his choice by selecting from a hyperlink?

Also, how do I transfer these settings when the person moves to another page in the website?

Thanks in advance...

12-14-2005, 03:57 PM
A PHP Switcher (http://www.alistapart.com/articles/phpswitch/) might be what you're looking for... :thumbsup:

12-14-2005, 04:05 PM
The switcher.php won't work on PHP 4.2 and above with the default setup, as it realises on register_globals. It also hits problems if the browser doesn't send the referrer, or there isn't one.

Here's my modified version:

setcookie ('sitestyle', $_GET['set'], time()+31536000, '/', 'yourdomain.com', '0');
if (empty($_SERVER['HTTP_REFERER']))
header('Location: /');
header("Location: $_SERVER[HTTP_REFERER]");

12-14-2005, 09:35 PM