/    Sign up×
Community /Pin to ProfileBookmark

Stylesheet selector *.php?ss=file

hi i have this php stylesheet selector which i am trying to edit

[code=php]
//stylesheet.php
<?php
if(isset($_COOKIE[“stylesheets”])) {
$val = $_COOKIE[“stylesheets”];
if ($val == “Green”) {
echo “<link rel=”stylesheet” href=”style-green.css” type=”text/css”>”;
}
else if ($val == “Red”) {
echo “<link rel=”stylesheet” href=”style-red.css” type=”text/css”>”;
}
else if ($val == “Black”) {
echo “<link rel=”stylesheet” href=”style-black.css” type=”text/css”>”;
}
else {
echo “<link rel=”stylesheet” href=”style-blue.css” type=”text/css”>”;
}
}
else {
echo “<link rel=”stylesheet” href=”style-blue.css” type=”text/css”>”;
}

//changeprefs.php
<?PHP

$loc = $_SERVER[“HTTP_REFERER”];
$css = $_GET[“file”];

setcookie(“stylesheets”,$css,time()+31536000); #one year
header (“Location:$loc”);

?>
[/code]

on page.php

<?php include(“stylesheet.php”); ?>
…..
….
<p><a href=”changeprefs.php?file=Blue”>Blue</a><br><br><img src=”table-title1.jpg” width=”100″></p>
<p><a href=”changeprefs.php?file=Green”>Green</a><br><br><img src=”table-title3.jpg” width=”100″></p>
<p><a href=”changeprefs.php?file=Red”>Red</a><br><br><img src=”table-title2.jpg” width=”100″></p>
<p><a href=”changeprefs.php?file=Black”>Black</a><br><br><img src=”table-title4.jpg” width=”100″></p>

what i am trying to do is a bit like id say zen garden so you have [url]http://www.site.com/index.php?stylesheet=layout.css[/url] or [url]http://www.site.com/index.php?stylesheet=http://www.othersite.com/style.css[/url]

something like that could anyone point me in right direction or help me out trying to figure this out

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Mar 02.2004 — What is the problem you are having?
Copy linkTweet thisAlerts:
@96turnerriauthorMar 02.2004 — hi thanks for replying

there is no problem with the code i pasted, i am just trying to extend it, just posted it as a starting basis for someone to hopefully have a go at

the stylesheet is taken from the address bar

This is what i am trying to achieve

http://www.site.com/index.php?ss=layout.css

would use layout.css

http://www.site.com/index.php?ss=style.css

would use style.css

http://www.site.com/index.php?ss=http://www.somesite.com/layout2.css

would use http://www.somesite.com/layout2.css
Copy linkTweet thisAlerts:
@SamMar 02.2004 — in that case, you don't need the whole cookie system. all you need is this:
[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Title</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="<?php $_GET['ss'];?>" />
</head>
[/code]
×

Success!

Help @96turnerri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...