Yeah, I thought about that but it means you have to keep storing all of that data in the database and retrieving it each time they change themes. Here is what I did and I think it worked:
The user goes to their profile page once they logged in, and can select a color scheme from a drop down box. When they submit that form, say they select "blue", it puts the option in the database, the variable (field) is called $style. Then, each time they login to the site, since it already has to pull their login and md5 password out of the database to compare with what they entered, it also grabs the $style, and registers it with the session, along with the login and password. So once they login, for example, now $style = "blue"; in the session. If they go back and change the theme, it will be re-registered with the session in that script.
Then there is an external file called styles.php that is called at the very start of every page, right below <body> like this: <?php include ('includes/styles.php') ?> which includes pure PHP, no display code.
That file has this code:
<?php
if ($style == "green")
{
$color1 = "aad13f";
$color2 = "567840";
$bgcolor = "49381D";
$header = "images/organic_header.jpg";
}
elseif ($style == "blue")
{
$color1 = "66CCFF";
$color2 = "3399FF";
$bgcolor = "49381D";
$header = "images/blue_header.jpg";
}
else
{
$color1 = "9966FF";
$color2 = "330099";
$bgcolor = "49381D";
$header = "images/organic_header.jpg";
}
?>
and the pages have all of the background colors set to like:
bgcolor="#<?php echo $color1;?>"
That way, all I have to do is update the external styles.php file and it will give them more color options. The external file will also feed the drop down box with the choices, I just haven't coded that. It actually works. Is there a better way to do this? The only problem is it isn't actually using a style sheet, but since I am only worried about colors, I can put all of the background and text colors, and images, in the styles.php file, and let the one style sheet control font sizes and positioning.
Is this a decent way to do this?