View Full Version : Skin Selector in PHP


iTom
04-21-2006, 09:40 PM
Ever wanted a site, where you could choose a skin? Well, here's your chance. With a little bit of PHP here and there, we can create one. Note that this uses CSS files ONLY - not whole website changes. Just your skin file :)

index.php:

<style type="text/css">
<?php
if(!$_GET['skin'] == '') {
$skin2load = $_GET['skin'];
$file_exists = @include($skin2load);
if($file_exists) {
include($skin2load);
$_SESSION['skinfile'] = $skin2load;
} else {
$skinerror = 1;
}
} else {
if($_SESSION['skinfile'] == "") {
include("v4a_default.css");
} else {
include($_SESSION['skinfile']);
}
}
?>
</style>
<?php
if($skinerror > 0) {
echo "Skin non-existant. ";
}
?>

Place that where you want your CSS to appear. REMEMBER - DO NOT USE <style> TAGS IN THE FILE.

This script remembers the skin you chose for the whole browser session. I wish I could post a link to my site containing the skinchanger but I think you can find it :)

Wherever you want the skinchanger menu to appear, place this HTML code.
<form action="" method="get">
<select name="skin">
<option value="skin1.css">skin1</option>
<option value="skin2.css">skin2</option>
<option value="skin3.css">skin3</option>
</select>
<input type="submit" name="submit" value="Go >>" />
</form>


THERE ARE NO LIMITS TO THE AMOUNT OF SKINS YOU CAN HAVE, although, I recommend three to four, varying from reallly basic, to super advanced for everyone to be happy.

I have only tested this on PHP 4.3 - it does NOT work on PHP 3, if you know about PHP 3 you probably can configure it to work. :D

~thomas.

iTom
04-22-2006, 02:07 PM
Sorry, I forgot:

ADD at the top of YOURFILE.PHP:
<?php session_start(); ?>