uramagget Posted July 13, 2007 Share Posted July 13, 2007 Hi, recently, before I moved hosts, my styleswitcher was working fine. Right now, I was trying to set the style, but it wouldn't work. Here's an example: http://www.sprites-unlimited.com/ The code in styleswitch.php is as follow: <?setcookie ('sitestyle', $set, time()+31536000, '/', 'sprites-unlimited.com', '0'); header("Location: $HTTP_REFERER"); ?> Yes, it's that A List Apart article, if you recognize this. It won't work. It returns a blank page for no reason. I made sure my style sheets existed. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/ Share on other sites More sharing options...
metrostars Posted July 13, 2007 Share Posted July 13, 2007 <? setcookie ('sitestyle', $set, time()+31536000, '/', 'sprites-unlimited.com', '0'); header("Location: ".$_SERVER['HTTP_REFERER']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297621 Share on other sites More sharing options...
uramagget Posted July 13, 2007 Author Share Posted July 13, 2007 The code doesn't work, even though it stops the blank page. If you could, please check my page source code: http://sprites-unlimited.com Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297664 Share on other sites More sharing options...
metrostars Posted July 13, 2007 Share Posted July 13, 2007 try posting the code that decides which style to include depending on the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297670 Share on other sites More sharing options...
metrostars Posted July 13, 2007 Share Posted July 13, 2007 <? setcookie('sitestyle', $_POST['set'], time()+31536000); header("Location: ".$_SERVER['HTTP_REFERER']); ?> I had a look through my cookies and it's not set at all. If the REFERER doesn't work you could always make the target for the form on the index page to <?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?> and then make the location = $_GET['oldURL'] Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297674 Share on other sites More sharing options...
MadTechie Posted July 13, 2007 Share Posted July 13, 2007 $_SERVER['HTTP_REFERER'] returns blank with some ISP's so i choose not to use it. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297680 Share on other sites More sharing options...
uramagget Posted July 13, 2007 Author Share Posted July 13, 2007 Referer works, though the cookie is not set. I can't seem to find my problem, it came out of the nowhere. Here's my stylesheet declaration: <link rel="stylesheet" type="text/css" title="default" href="<?php echo (!$sitestyle)?'default':$sitestyle ?>.css" /> <link rel="alternate stylesheet" type="text/css" title="blue" href="blue.css"> <link rel="alternate stylesheet" type="text/css" title="orange" href="orange.css"> Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297778 Share on other sites More sharing options...
MadTechie Posted July 14, 2007 Share Posted July 14, 2007 check the $_POST['set'] Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297811 Share on other sites More sharing options...
uramagget Posted July 14, 2007 Author Share Posted July 14, 2007 That doesn't work, it returns the same results. EDIT: I'm using PHP 5.2.3, if that helps. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-297854 Share on other sites More sharing options...
MadTechie Posted July 14, 2007 Share Posted July 14, 2007 do you mean $_POST['set'] is not changing ? can you post some more code please Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298031 Share on other sites More sharing options...
uramagget Posted July 14, 2007 Author Share Posted July 14, 2007 styleswitch.php <? setcookie('sitestyle', $_POST['set'], time()+31536000); header("Location: ".$_SERVER['HTTP_REFERER']); ?> index.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Sprites Unlimited // The Ultimate Resource</title> <link href="http://sprites-unlimited.com/favicon.ico" rel="shortcuticon" type="image/icon"> <base href="sprites-unlimited.com/"> <link rel="stylesheet" type="text/css" title="default" href="<?php echo (!$sitestyle)?'default':$sitestyle ?>.css" /> <link rel="alternate stylesheet" type="text/css" title="blue" href="blue.css"> <link rel="alternate stylesheet" type="text/css" title="orange" href="orange.css"> <meta name="keywords" content="Sprites,SPRITES,sprites,sprites unlimited,megaman,pokemon,kirby,sprites unlimited,unlimited sprites,game sprites"> <meta name="description" content="Rather Mediocre collection of sprites for NES,SNES,N64,GBA,GB,Genesis, & more!"> <meta name="robots" content="index,follow"> <meta name="revisit-after" content="1"> </head> <body> <div id="header"> </div> <div id="container"> <div id="content"> <div align="center"> <form action="styleswitch.php" method="post"> <select name="set"> <option value="default" selected>56K White</option> <option value="orange">Classic Orange</option> <option value="blue">Icicle Blue</option> </select> <input type="submit" value="Change Style"> </form> <a href="http://www.dino-productions.net/"><img src="http://www.drunkduck.com/Megaman_EXE/gfx/DP.PNG" border="0" alt="Dino Productions"></a><BR> <a href="http://www.drunkduck.com/Megaman_EXE/index.php"><img src="http://www.drunkduck.com/Megaman_EXE/gfx/EXE.PNG" border="0" alt="Megaman EXE"></a><BR> <a href="http://www.sprites-unlimited.com/forum/index.php"><img src="http://www.drunkduck.com/Megaman_EXE/gfx/DPNET.PNG" border="0" alt="DP NET"></a><BR> </div> <hr> <?php //Main Variables $misc = "misc.php"; $news = "cutenews/show_news.php"; $error = "404.php"; $ext = ".php"; //Include Misc stuff include $misc; //Include News, and use ?id= if(!isset($_GET['id'])){ include $news; } elseif($_GET['id'] == "main") { include $misc; include $news; } elseif(isset($_GET['id']) && file_exists($_GET['id'].$ext)){ include $_GET['id'].$ext; } //404 Error Page else{ include $error; } ?> </div> <div align="center"> <a href="http://www.drunkduck.com/Megaman_EXE/index.php" target="_blank"><img src="http://img79.imageshack.us/img79/7898/syxbh4.png" border="0" alt="By me"></a> </div> <div id="leftmenu"> <ul> <h1>Site</h1> <ul> <li><a href="/">Home</a></li> <li><a href="?id=Tutorial">Ripping tutorial</a></li> <li><a href="?id=staff">Staff</a></li> <li><a href="?id=Contact">Submit/Contact</a></li> <li><a href="?id=LinkUs">Link to Us</a></li> <li><a href="?id=Links">Links</a></li> <li><a href="?id=disclamer">Disclaimer</a></li> </ul> <h1>Games</h1> <ul> <li><a href="?id=Classic">Classic</a></li> <li><a href="?id=NES">NES</a></li> <li><a href="?id=SNES">SNES</a></li> <li><a href="?id=GBC">Game Boy</a></li> <li><a href="?id=GBA">GBA</a></li> <li><a href="?id=Genisis">Genesis</a></li> <li><a href="?id=DS">Nintendo DS</a></li> <li><a href="?id=PC">PC/Internet</a></li> <li><a href="?id=Custom">Custom</a></li> <li><a href="?id=map">Game Maps</a></li> </ul> <h1>Affiliates</h1> <ul> <li><a href="http://www.sprites-inc.co.uk/" target="_blank"><img src="http://img144.imageshack.us/img144/9117/inchs4.png" border="0" alt="Sprites Inc."></a></li> <li><a href="http://www.parahosting.net/" target="_blank"><img src="http://www.parahosting.net/images/button2.png" border="0" alt="Parasyte Hosting"></a></li> <li><a href="http://www.pokeuniverse.co.nr" target="_blank"><img src="http://i15.photobucket.com/albums/a396/ACTIONGAMER/affybuttons/affylink9cs.png" border="0" alt="Pokeuniverse"></a></li> <li><a href="http://www.bmestudioz.com/" target="_blank"><img src="http://i15.photobucket.com/albums/a396/ACTIONGAMER/affybuttons/bmestudioz.gif" border="0" alt="BME Studioz"></a></li> <li><a href="http://www.vglan.com/" target="_blank"><img src="images/VGlan.PNG" border="0" alt="Video Game LAN"></a></li> </ul> <h1>Topsites</h1> <ul> <a href="http://www.parahosting.net/topsites/index.php?a=in&u=spaceyoshix"><img src="http://www.parahosting.net/topsites/button.php?u=spaceyoshix" alt="Parasyte Top10 Hostees" border="0" /></a> <a href="http://www.bmestudioz.com/topsites/" target="_blank"><img src="http://www.bmestudioz.com/topsites/button.php?u=spaceyoshix" alt="BME StudioZ Topsites" border="0" /></a> </ul> <h1>Links</h1> <ul> <li><a href='http://tsgk.captainn.net/' target="_blank"><img src="http://tsgk.captainn.net/img/banner_88x31_tsgk-03.png" border=0 alt='The ShyGuy Kingdom'></a></li> </ul> <h1>Statistics</h1> <ul> <li><script type="text/javascript" language="javascript"> var sc_project=1751497; var sc_invisible=0; var sc_partition=16; var sc_security="7f833bfb"; var sc_text=2; </script> Hits:<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img src="http://c17.statcounter.com/counter.php?sc_project=1751497&java=0&security=7f833bfb&invisible=0" alt="site stats" border="0"></a> </noscript></li> <li>Online:<script type="text/javascript" src="http://fastonlineusers.com/on3.php?d=www.sprites-unlimited.awardspace.com"></script></li> </ul> </ul> </div> </div> </div> </body> </html> I'm using PHP 5.2.3 Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298119 Share on other sites More sharing options...
AndyB Posted July 14, 2007 Share Posted July 14, 2007 Am I missing something? Where do you actually READ the cookie value? Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298276 Share on other sites More sharing options...
uramagget Posted July 14, 2007 Author Share Posted July 14, 2007 http://www.alistapart.com/articles/phpswitch/ According to that, styleswitch.php sets the cookie, though it won't set it... Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298309 Share on other sites More sharing options...
uramagget Posted July 15, 2007 Author Share Posted July 15, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298792 Share on other sites More sharing options...
MadTechie Posted July 15, 2007 Share Posted July 15, 2007 why do you say it won't set the cookie ? the php side in isn't using cookies so i fail to see the cookie problem! Edit: did you read the article correctly i think you should read it again!!! Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298811 Share on other sites More sharing options...
uramagget Posted July 15, 2007 Author Share Posted July 15, 2007 There's nothing more to read, and in the first post I said that the styleswitcher just broke by itself, it didn't break because I modified anything. It _just_broke_ Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298844 Share on other sites More sharing options...
AndyB Posted July 15, 2007 Share Posted July 15, 2007 I think the problem is that the COOKIE is never read, which means the switcher isn't going to switch regardless of how many times the cookie value is changed. I suspect it_just_broke when you/your host upgraded php to a version that has register_globals OFF Here's an example php switcher that READS the cookie value - http://gr0w.com/articles/code/css_stylesheet_switcher_using_php/index.php Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-298855 Share on other sites More sharing options...
uramagget Posted July 16, 2007 Author Share Posted July 16, 2007 I've done the article re-read three times already and it won't work. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-299517 Share on other sites More sharing options...
MadTechie Posted July 16, 2007 Share Posted July 16, 2007 you reading the WHOLE thing Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-299600 Share on other sites More sharing options...
per1os Posted July 16, 2007 Share Posted July 16, 2007 I've done the article re-read three times already and it won't work. Did you switch from a server to localhost? Either way if you did let me know, localhost has different cookie rules. Change this part of your code: <link rel="stylesheet" type="text/css" title="default" href="<?php echo isset($_COOKIE['sitestyle'])?$_COOKIE['sitestyle']:'default'; ?>.css" /> As everyone pointed out, you were never reading from the cookie and as thorpe (I believe pointed out) you are assuming register_globals was on which is a huge security risk. Give the above a try. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-299606 Share on other sites More sharing options...
uramagget Posted July 16, 2007 Author Share Posted July 16, 2007 I've been trying to have this solved even by the List Apart people, but it won't work, so I have no idea as to why this is happening, because I haven't touched the code for it to be fubared. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-299893 Share on other sites More sharing options...
per1os Posted July 17, 2007 Share Posted July 17, 2007 <?php setcookie ('sitestyle', $_POST['set'], time()+31536000, '/', 'sprites-unlimited.com'); header("Location: " . $_SERVER['HTTP_REFERER']); ?> It sounds like your version of PHP was upgraded recently. Try the above, omit the '0' from the setcookie because that is for the SSL connection, it is assumed to be off and unnecessary. Use $_POST and $_SERVER incase the register_globals was turned off (better that way anyways). Use <?php incase the <? tag was also turned off (as it is depreciated in later versions). Give that a try plus the other post I posted and see what the results are. Quote Link to comment https://forums.phpfreaks.com/topic/59859-styleswitcher-problem/#findComment-300012 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.