I am trying to build a php style switcher for my website, this is what I am using in the head of the document
<?php
$layout = (isset($_COOKIE['layout']) && ($_COOKIE['layout'] == "grey")) ? "grey" : "main";
?>
<style type="text/css" media="screen,projection">
@import '<?php echo $layout; ?>.css';
</style>
and the link to change the style is like this
<a href="www.greenermountian.net/switcher/" >click here to change to grey style!</a>
this is in the www.greenermountian.net/switcher/index.php
<?php
$layout = (isset($_COOKIE['layout']) && ($_COOKIE['layout'] == "grey")) ? "main" : "grey";
setcookie("layout", $layout, time()+31536000, '/');
$ref = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : "http://{$_SERVER['SERVER_NAME']}/";
header("Location: $ref");
?>
when I put it all together I get the following error message:
Warning: Cannot modify header information - headers already sent by (output started at /home/drrichar/public_html/greenermountian/styleswitch/index.php:1) in /home/drrichar/public_html/greenermountian/styleswitch/index.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at /home/drrichar/public_html/greenermountian/styleswitch/index.php:1) in /home/drrichar/public_html/greenermountian/styleswitch/index.php on line 5
all grey.css and main.css are in the root directory.
Any help would be appriciated!