Jump to content

Archived

This topic is now archived and is closed to further replies.

XeroXer

Multiple ?id=1

Recommended Posts

[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...

Share this post


Link to post
Share on other sites
<a href="index.php?id=1&amp;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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
you'd just save the cookie when they pick the stylesheet, and load it when they load a page.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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]<?php
setcookie('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.

Share this post


Link to post
Share on other sites
And it's $css = $_COOKIE['css'];

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.