I currently have a web site where users can select a custom theme. After they choose the theme, a cookie is created. The cookie contains the correct data and points to the correct CSS file. For some reason, upon re-visiting the site, the theme is not loaded. I should point out that I am new to PHP so it may be a very easy mistake. Please help. Thank you.
Here is my code:
<?php
$stylesArr = array('Default', 'Black', 'Pink', 'Green', 'Red');
if(isset($_GET['theme']) && in_array($_GET['theme'], $stylesArr)) {
$style = 'CSS/' . $_GET['theme'] . '.css';
setcookie("theme", $style, time()+(60*60*24*30));
} else {
if(isset($_COOKIE['theme']) && in_array($_COOKIE['theme'], $stylesArr)) {
$style = 'CSS/' . $_COOKIE['theme'] . '.css';
} else {
$style = 'CSS/Default.css';
}
}
?>
<link rel="stylesheet" href="<?php echo $style>" type="text/css"media="screen" />