/    Sign up×
Community /Pin to ProfileBookmark

PHP css switcher

I’m trying to make a PHP css switcher so you can simply click a link and it will change the color schemes. I’ve been trying for quite a while now and can’t seem to get it to work.

Site [url]http://illegal3alien.ath.cx[/url] (dyndns)
Main Page – [url]http://illegal3alien.ath.cx/main.php[/url]

[code=html]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<link rel=”stylesheet” type=”text/css” media=”screen” title=”User Defined Style” href=”<?php echo (!$sitestyle)?’main’:$sitestyle ?>.css” />
</head>

<body>
<a href=”switcher.php?set=red”>click here to change to RED style!</a>
</body>
</html>[/code]

The switcher.php code is:

[code=php]<?php
setcookie (‘sitestyle’, $set, time()+31536000,’/’, ‘illegal3alien.ath.cx’, ‘0’);
header(“Location: $HTTP_REFERER”);
?>[/code]

Anyone tell me what’s wrong and how to fix it?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@njvenauthorMar 05.2009 — Yah! Finally got it. I had to change the statement in the main page to [code=php]<?php echo (!$_COOKIE['styleselected'])?'main':$_COOKIE['stylesselected'] ?>[/code]

And also change the switcher to:
[code=php]<?php
setcookie ('styleselected', $_GET['set'], time()+31536000,'/', 'illegal3alien.ath.cx', '0');
header("Location: http://illegal3alien.ath.cx/page.php");
?>[/code]
×

Success!

Help @njven 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.18,
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,
)...