|
Posted by Amanda H. on 02/16/06 00:02
My bad! Here is the PHP script, sans bulk of notes:
<?
header('Content-Type: text/css');
// CONFIGURATION
// If you want to specify a default CSS file for users who can't handle
// cookies, replace styles.css with the filename below:
$basicsheet = "basic.css";
// CHECK IF NEW STYLESHEET IS BEING LOADED
if(isset($_GET['sheet']) OR isset($_POST['sheet'])) {
// CHECK IF FILE IS SPECIFIED IN URL
if(isset($_GET['sheet'])) { $newsheet = $_GET['sheet']; }
// CHECK IF FILE IS SPECIFIED IN FORM DATA
if(isset($_POST['sheet'])) { $newsheet = $_POST['sheet']; }
// MAKE THE USER REMEMBER WHICH STYLESHEET IS LOADED
setcookie("my_stylesheet", "$newsheet.css", 0, "/");
// SEND THE USER BACK
$ref = $_SERVER['HTTP_REFERER'];
header("Location: $ref");
} else {
// NORMAL STYLESHEET REQUEST
$mysheet = $_COOKIE['my_stylesheet'];
if($mysheet == "") { $mysheet = $basicsheet; }
include "$mysheet";
}
?>
---end of PHP script. Then the link header for the HTML file is:
<link rel="stylesheet" type="text/css"
href="http://www.amandahenson.com/styleswitcher.php" />
---end of link. It works in most browsers, but has the problems as
stated in the originl post.
[Back to original message]
|