vote-for-pedro Posted June 26, 2007 Share Posted June 26, 2007 Hi noob on the board here i hope someone can help me. im using cookies on my site they define what style sheet is to be used. only problem is until the user selects a style no cookie is made. im using this code to show a piece of flash. if(isset($_COOKIE['STYLE'])) { include($_COOKIE['STYLE'].'.php'); exit; } else { include("0.php") { i can use include($_COOKIE['STYLE'].'.php'); to show the flash if there is a cookie but other wise nothing will show up. include("0.php") will work on its own but the whole thing together wont work. im pretty sure ive made a simple mistake but i cant see it. ive also tryed using the include($_COOKIE['STYLE'].'.php'); break; default: require('0.php'); but no good either. Any advice? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/57276-solved-else-include-and-cookies-dont-mix/ Share on other sites More sharing options...
aim25 Posted June 26, 2007 Share Posted June 26, 2007 Well wat is 0.php? Link to comment https://forums.phpfreaks.com/topic/57276-solved-else-include-and-cookies-dont-mix/#findComment-283108 Share on other sites More sharing options...
Dragen Posted June 26, 2007 Share Posted June 26, 2007 That's a neater way of putting it. Saves on using the elseif's. If $_COOKIE['STYLE'] isn't set $style defaults to 0, so including $style should work fine. <?php $style = isset($_COOKIE['STYLE']) ? $_COOKIE['STYLE'] : '0'; include($style . '.php'); ?> Link to comment https://forums.phpfreaks.com/topic/57276-solved-else-include-and-cookies-dont-mix/#findComment-283114 Share on other sites More sharing options...
vote-for-pedro Posted June 26, 2007 Author Share Posted June 26, 2007 Dragen that worked great thanks for the promt reply what a great forum! Link to comment https://forums.phpfreaks.com/topic/57276-solved-else-include-and-cookies-dont-mix/#findComment-283135 Share on other sites More sharing options...
Dragen Posted June 26, 2007 Share Posted June 26, 2007 no problem.. I think it was thorpe.. or frost that pointed out that method of checking variables with isset. Link to comment https://forums.phpfreaks.com/topic/57276-solved-else-include-and-cookies-dont-mix/#findComment-283144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.