I am trying to use a stylesheet switcher as discussed at <!-- m --><a class="postlink" href="http://www.alistapart.com/articles/phpswitch/">http://www.alistapart.com/articles/phpswitch/</a><!-- m --> but i cant get it to work.
I wondered if anyone would mind having a look and seeing if they can work out whats wrong.
<?php
session_start();
?>
<?php
if(isset($_GET['css'])){
switch ($_GET['css']) {
case 'mhwell2':
$stylesheet = '<link href=http://www.htmlforums.com/archive/index.php/"mhwell2.css" type="text/css" rel="stylesheet">';
$_SESSION['csschanger']=$stylesheet;
break;
default:
$stylesheet = '<link href=http://www.htmlforums.com/archive/index.php/"mhwell1.css" type="text/css" rel="stylesheet">';
$_SESSION['csschanger']=$stylesheet;
}
}
?>
In the header of the php/xhtml file i have:
<?php echo ($_SESSION['csschanger'])? $_SESSION['csschanger']: '<link href=http://www.htmlforums.com/archive/index.php/"mhwell1.css" type="text/css" rel="stylesheet">' ;?>
and i use links to change the style sheet with the following code:
Select <A href=http://www.htmlforums.com/archive/index.php/"<?php echo $_SERVER['PHP_SELF']; ?>?css=mhwell2">[leaves]</a>
or <A href=http://www.htmlforums.com/archive/index.php/"<?php echo $_SERVER['PHP_SELF']; ?>?css=default">[sunflower]</a></p>
I really dont know php at all which is why i've borrowed a script so please dont baffle me with technospeak. The reason I want to use php rather than javascript is because of accessibility and backwards compatibility.well what does it not do? looks ok to me at first glance.it doesnt switch style sheets as its supposed todo you have a test page or something. are the sessions getting set? is the stylesheet link getting set? what does the output look like?Originally posted by k2.
In the header of the php/xhtml file i have:
<?php echo ($_SESSION['csschanger'])? $_SESSION['csschanger']: '<link href=http://www.htmlforums.com/archive/index.php/"mhwell1.css" type="text/css" rel="stylesheet">' ;?>
Do you do a <?php session_start(); ?> at the beginning of each file that is trying to access the $_SESSION variables?As I said i used a ready made script off the net so I dont know where session_start() would go.
where would i put it? where should it be?
I'll try and post a sample page for you to look at this afternoon (uk time)It goes at the very top of your page, before the <html> tag. So it looks like this...
<?php session_start(); ?>
<html>
<head>
<title>Your Title</title>
</head>
<body>
Your Content
</body>
</hmtl>
I wondered if anyone would mind having a look and seeing if they can work out whats wrong.
<?php
session_start();
?>
<?php
if(isset($_GET['css'])){
switch ($_GET['css']) {
case 'mhwell2':
$stylesheet = '<link href=http://www.htmlforums.com/archive/index.php/"mhwell2.css" type="text/css" rel="stylesheet">';
$_SESSION['csschanger']=$stylesheet;
break;
default:
$stylesheet = '<link href=http://www.htmlforums.com/archive/index.php/"mhwell1.css" type="text/css" rel="stylesheet">';
$_SESSION['csschanger']=$stylesheet;
}
}
?>
In the header of the php/xhtml file i have:
<?php echo ($_SESSION['csschanger'])? $_SESSION['csschanger']: '<link href=http://www.htmlforums.com/archive/index.php/"mhwell1.css" type="text/css" rel="stylesheet">' ;?>
and i use links to change the style sheet with the following code:
Select <A href=http://www.htmlforums.com/archive/index.php/"<?php echo $_SERVER['PHP_SELF']; ?>?css=mhwell2">[leaves]</a>
or <A href=http://www.htmlforums.com/archive/index.php/"<?php echo $_SERVER['PHP_SELF']; ?>?css=default">[sunflower]</a></p>
I really dont know php at all which is why i've borrowed a script so please dont baffle me with technospeak. The reason I want to use php rather than javascript is because of accessibility and backwards compatibility.well what does it not do? looks ok to me at first glance.it doesnt switch style sheets as its supposed todo you have a test page or something. are the sessions getting set? is the stylesheet link getting set? what does the output look like?Originally posted by k2.
In the header of the php/xhtml file i have:
<?php echo ($_SESSION['csschanger'])? $_SESSION['csschanger']: '<link href=http://www.htmlforums.com/archive/index.php/"mhwell1.css" type="text/css" rel="stylesheet">' ;?>
Do you do a <?php session_start(); ?> at the beginning of each file that is trying to access the $_SESSION variables?As I said i used a ready made script off the net so I dont know where session_start() would go.
where would i put it? where should it be?
I'll try and post a sample page for you to look at this afternoon (uk time)It goes at the very top of your page, before the <html> tag. So it looks like this...
<?php session_start(); ?>
<html>
<head>
<title>Your Title</title>
</head>
<body>
Your Content
</body>
</hmtl>