XeroXer Posted August 2, 2006 Share Posted August 2, 2006 [u][b]Hi there.[/b][/u]I am making a page where I want the user to be able to specify what look they want the page in.So that on the startpage there shall be different colored squares that they can click.And if they click the red one the design pick my [color=red][b]red.css[/b][/color] file to use.By doing this I use the [color=red][b]?css=1[/b][/color] and different numbers.Thought that creates a problem.I use the [color=red][b]?id=1[/b][/color] to choose what page to show.How do I do so that I can have more of these :-)...I have seen pages using [color=red][b]index.php?id=1&?css=3[/b][/color].Is this easy to do or?Or maybe someone has a different idea on how to do the style switching?Maybe using cookies so that if they return to the page the style they chose is still used.Please post any tips you can think of... Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 2, 2006 Share Posted August 2, 2006 <a href="index.php?id=1&css=1">That's one way of doing it, and the easiest...And you can also do a cookie thing so that the style will remain for the next visit. Quote Link to comment Share on other sites More sharing options...
XeroXer Posted August 2, 2006 Author Share Posted August 2, 2006 But if I use cookies to save the theme they selected do I still need ?css=1 or can I make it any other way? Quote Link to comment Share on other sites More sharing options...
DaveLinger Posted August 2, 2006 Share Posted August 2, 2006 you'd just save the cookie when they pick the stylesheet, and load it when they load a page. Quote Link to comment Share on other sites More sharing options...
XeroXer Posted August 2, 2006 Author Share Posted August 2, 2006 Ok!How do I create a link that saves a cookie with the color information and then reloades the site to show the color they chose?All the questions is because the first time I ever used cookies with a php script was yesterday. :-)Because this would work to chek it right?[code]<head><?php$css = "$_COOKIE[css]";if $css == "red" { $stylecss = "style_red.css"; }elseif $css == "blue" { $stylecss = "style_blue.css"; }elseif $css == "green" { $stylecss = "style_green.css"; }elseif $css == "brown" { $stylecss = "style_brown.css"; }else { $stylecss = "style.css"; }?><link href="<?php echo $stylecss; ?>" rel="stylesheet" type="text/css"></head>[/code]I know that I can use:[code]<?php setcookie("css", "red", time()+36000);?>[/code]but not how to embed it into a link... Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted August 2, 2006 Share Posted August 2, 2006 just put that setcookie on top of a page that you will link to. say you have a link "changestyle.php?css=red", then on that changestyle.php page you can do[code]<?phpsetcookie('css',$_GET['css'],time()+36000);header('Location: index.php');?>[/code]you can also make a dropdown list and a form for them to change the theme. Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 2, 2006 Share Posted August 2, 2006 And it's $css = $_COOKIE['css']; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.