Zend - The PHP Company




HTML

Add Code


ColorMe  

Type: code fragment
Added by: Thanders
Entered: 04/06/2001
Last modified: 06/12/2000
Rating: - (fewer than 3 votes)
Views: 6440
Use PHP and CSS to let users choose a color scheme for your site.


************************************************
* This application consists of 2 php documents  *
************************************************

//page1.php.
//Put this code between the <head> tags

<?
if ($Stylesheet == ""
{
echo 
"<link rel='STYLESHEET' type='text/css' href='default.css'>";
}
else 
{
echo 
"<link rel='STYLESHEET' type='text/css' href='".$HTTP_COOKIE_VARS["Stylesheet"]."'>";
}
?>

//page1.php
//put this code anywhere between the body of the document.

<form action="page2.php" method="post">
<select name="css">
<!-- change option value to your stylesheets -->
<option value="blue.css">Red</option>
<option value="grey.css">Blue</option>
<option value="default.css">Default</option>
</select>
<input type="submit" value="Set stylesheet">
</form>


//page2.php
//put this code at the beginning of your document(before anything else)

<?
setcookie 
("Stylesheet""$css");
?>

//page2.php
//and this link to go back to page1.php and you can see the canges. Pretty simple ;)


Usage Example




Rate This Script





Search



This Category All Categories