Joe 90
06-10-2007, 14:24
Howdo,
yesterday i tried to make a php based style switcher... and now my site wont load my style sheets, but rather than give in - i'm still in search of an answer...
anyway, heres my code -
<link rel="stylesheet" href="<?php print $currentstyle; ?>" type="text/css" />
<?php
// Set Default Style
$currentStyle = 'bridge.css';
// Check to see if the page was posted back
if(isset($_POST["submit"]))
{
// Find out if they want to set or delete a cookie
if($_POST["style"] == "none")
{
// Unset the Cookie
setcookie("style", "", time()-288000);
}
// Set Current Style
$currentStyle = $_POST["style"] . ".css";
// Set the requested Style to a cookie
setcookie("style", $_POST["style"], time()+288000);
} else {
// Check Cookie for Style
if(isset($_COOKIE["style"]))
{
// Use Style From Cookie
$currentStyle = $_COOKIE["style"] . ".css";
} else {
// Set Default Style
$currentStyle = 'bridge.css';
}
}
?>
<form method="post" action="../css/setstylecookie.php">
<select name="style">
<option value="none">No Styles</option>
<option value="bridge">Bridge</option>
<option value="show">Old School</option>
<input type="submit" name="submit" value="set" />
</select>
</form>
then obviously i have 3 CSS files - bridge.css, show.css and none.css
and my dir tree is a little bit like...
./
./head.php
./includes
../css/
..../bridge.css
..../setstylecookie.php
../php/
..../submenu.php
don't suppose we have any php legends in here do we? ;D
yesterday i tried to make a php based style switcher... and now my site wont load my style sheets, but rather than give in - i'm still in search of an answer...
anyway, heres my code -
<link rel="stylesheet" href="<?php print $currentstyle; ?>" type="text/css" />
<?php
// Set Default Style
$currentStyle = 'bridge.css';
// Check to see if the page was posted back
if(isset($_POST["submit"]))
{
// Find out if they want to set or delete a cookie
if($_POST["style"] == "none")
{
// Unset the Cookie
setcookie("style", "", time()-288000);
}
// Set Current Style
$currentStyle = $_POST["style"] . ".css";
// Set the requested Style to a cookie
setcookie("style", $_POST["style"], time()+288000);
} else {
// Check Cookie for Style
if(isset($_COOKIE["style"]))
{
// Use Style From Cookie
$currentStyle = $_COOKIE["style"] . ".css";
} else {
// Set Default Style
$currentStyle = 'bridge.css';
}
}
?>
<form method="post" action="../css/setstylecookie.php">
<select name="style">
<option value="none">No Styles</option>
<option value="bridge">Bridge</option>
<option value="show">Old School</option>
<input type="submit" name="submit" value="set" />
</select>
</form>
then obviously i have 3 CSS files - bridge.css, show.css and none.css
and my dir tree is a little bit like...
./
./head.php
./includes
../css/
..../bridge.css
..../setstylecookie.php
../php/
..../submenu.php
don't suppose we have any php legends in here do we? ;D