update_styles.php
<?php
$new_style = strip_tags( $_GET['style'] ); //the style the user has selected
$styles = array( "blue", "red", "green" ); //the styles they can have
if ( !in_array( $new_style, $styles ) ) //selected an invalid style
{
echo "You can not have this style";
}
else //selected a valid style
{
setcookie( "style", $new_style, time() + 60 * 60 * 24 * 5 ); //update "style" cookie
echo "Your style has been updated to {$new_style}!";
}
?>
index.php
<?php
$style = ( $_COOKIE['style'] ) ? $_COOKIE['style'] : "blue"; //if the "style" cookie has been set, read it, if not use "blue" as default style
echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"css/{$style}.css\" media=\"screen\" />"; //print out the html line that will get the CSS file.
?>
Then just use something like this to switch between stylesheets.
Change theme:
<a href="update_style.php?style=blue">Blue</a> |
<a href="update_style.php?style=red">Red</a> |
<a href="update_style.php?style=green">Green</a>