Natechs Posted August 19, 2008 Share Posted August 19, 2008 I have three stylesheets, and I want the user to be able to change back and forth at will. But I don't know how to do that. Also, the logo changes too.Logo code:<div id="header"><!-- Header --><a href="/"><img src="logo.gif" alt="Nathan C:: Web Designer" /></a></div>I want to keep the hyper link and centering. I can live without the link but I really want the centering.Thanks,Nathan. Link to comment Share on other sites More sharing options...
Synook Posted August 19, 2008 Share Posted August 19, 2008 You could have a session variable that defines the stylesheet. The banner can be a division that has its background defined in the stylesheet.http://www.w3schools.com/php/php_sessions.asp Link to comment Share on other sites More sharing options...
Natechs Posted August 19, 2008 Author Share Posted August 19, 2008 Is there any other code I need? Link to comment Share on other sites More sharing options...
Synook Posted August 19, 2008 Share Posted August 19, 2008 You'll need some code to set the session var based on the user's selection, e.g. switch.php <?php session_start(); $_SESSION['style'] = $_GET['style']; header("location:{$_SERVER['HTTP_REFERER']}");?> Some links: <a href="switch.php?style=style1">Style 1</a> <a href="switch.php?style=style2">Style 2</a> And the style definition using the session var: <link rel="stylesheet" type="text/css" href="<?php echo $_SESSION['style']; ?>" /> Don't forget to put session_start() before output on all your pages! Link to comment Share on other sites More sharing options...
Natechs Posted August 20, 2008 Author Share Posted August 20, 2008 Is there a way to make it so that there is a default style so that my page is styled when someone first sees it and keeps the style changing feature? Link to comment Share on other sites More sharing options...
Synook Posted August 20, 2008 Share Posted August 20, 2008 You can use a conditional to specify the stylesheet if the SESSION var isn't set <link rel="stylesheet" type="text/css" href="<?php echo isset($_SESSION['style']) ? $_SESSION['style'] : "defaultstyle.css"; ?>" /> Link to comment Share on other sites More sharing options...
Natechs Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks Synook. I am very happy for people like you! Link to comment Share on other sites More sharing options...
Natechs Posted August 27, 2008 Author Share Posted August 27, 2008 Last question: Is there a way that when the user closes their browser then views my site again, the style still stays like when they closed it? Link to comment Share on other sites More sharing options...
Lulzim Posted August 27, 2008 Share Posted August 27, 2008 Last question: Is there a way that when the user closes their browser then views my site again, the style still stays like when they closed it?Use cookies instead of sessions Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.