cordoprod Posted July 14, 2008 Share Posted July 14, 2008 Hello. sorry about all the questions But anyway, i need a navigation... Here's my code: <?PHP $nav = $_GET['s']; $array = array("nyheter", "false", "vip", "false", "glemt_passord", "false", "bli_medlem", "false", "bekreftelse", "false", "statistikk", "false", "regler", "false", ); foreach ( $array as $page => $permission ) { if(!$logged_in and $permission != "false") echo "Du må være logget inn for å se denne siden."; elseif(!$logged_in and $permission == "false") include($_GET['s']); elseif($logged_in) include($_GET['s']); else include("nyheter.php"); } ?> I just get plenty of these error messages: Du må være logget inn for å se denne siden. Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:') in /customers/cordoproduction.com/cordoproduction.com/httpd.www/teenchill/index.php on line 213 Du må være logget inn for å se denne siden. Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:') in /customers/cordoproduction.com/cordoproduction.com/httpd.www/teenchill/index.php on line 213 Du må være logget inn for å se denne siden. Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:') in /customers/cordoproduction.com/cordoproduction.com/httpd.www/teenchill/index.php on line 213 Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/ Share on other sites More sharing options...
sader Posted July 14, 2008 Share Posted July 14, 2008 I think /customers/cordoproduction.com/cordoproduction.com/httpd.www/teenchill/index.php doesn't exist, so check your file path carefully Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-589949 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 it does, it has to be something with the code Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-589953 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 I updated the code a bit.. forgot to put .php in the end.. lol <?PHP $nav = $_GET['s']; $array = array("nyheter", "false", "vip", "false", "glemt_passord", "false", "bli_medlem", "false", "bekreftelse", "false", "statistikk", "false", "regler", "false", ); foreach ( $array as $page => $permission ) { if(!$logged_in and $permission != "false") echo "Du må være logget inn for å se denne siden."; elseif(!$logged_in and $permission == "false") include($_GET['s'].".php"); elseif($logged_in) include($_GET['s'].".php"); else include("nyheter.php"); } ?> but now, not only one page will be included, plenty will.. same page.. if i have user.php more than one of the page will appear.. Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-589964 Share on other sites More sharing options...
sader Posted July 14, 2008 Share Posted July 14, 2008 try this fix first $array = array ( "nyheter"=> "false", "vip"=> "false", "glemt_passord"=>"false", ... ); Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-589972 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 no change.. Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-589985 Share on other sites More sharing options...
sader Posted July 14, 2008 Share Posted July 14, 2008 Generally I can't understand what You trying to do. Why all premissions are "false"? Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-590010 Share on other sites More sharing options...
cordoprod Posted July 15, 2008 Author Share Posted July 15, 2008 I'll try to explain it. False means that the user does not have to be logged in.. The other pages aren't in that array.. It's a lot of pages and i tried to just set the pages who didn't have to be logged in to see. Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-590295 Share on other sites More sharing options...
cordoprod Posted July 15, 2008 Author Share Posted July 15, 2008 I did some changes.. only one page appears now, cus i added a break. But even though the user is not logged in it can see the pages which don't have false. Anyway, here's my code.. <?PHP $nav = $_GET['s']; $array = array("nyheter" => "false", "vip" => "false", "glemt_passord" => "false", "bli_medlem" => "false", "bekreftelse" => "false", "statistikk" => "false", "regler" => "false", ); if($nav == "") $nav = "nyheter"; foreach ( $array as $page => $permission ) { if(!$logged_in and $permission == "false") { echo "Du må være logget inn for å se denne siden."; break; } elseif(!$logged_in and $permission == "false") { include($nav.".php"); break; } elseif($logged_in) { include($nav.".php"); break; } else { include("nyheter.php"); break; } } ?> And, $logged_in is $_SESSION['logged_in'] if it makes a difference.. Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-590338 Share on other sites More sharing options...
cordoprod Posted July 15, 2008 Author Share Posted July 15, 2008 Can somebody tell me what's wrong with this... even though the user is logged in it will have access to pages which don't have 1. <?PHP $nav = $_GET['s']; $array = array("nyheter" => 1, "vip" => 1, "glemt_passord" => 1, "bli_medlem" => 1, "bekreftelse" => 1, "statistikk" => 1, "regler" => 1, ); $allow = 0; foreach ( $array as $page[$nav] => $permission ) { if($permission == 1) { $allow = 1; break; } elseif($logged_in and $permission != 1) { $allow = 1; break; } else { $allow = 0; break; } } if(file_exists($nav.".php") && $allow = 1) { include($nav.".php"); } else include ("nyheter.php"); ?> You see, pages in the array is pages a user who is not logged in can access... do i have to add the users with permission 0 to the array ? Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-590435 Share on other sites More sharing options...
sader Posted July 17, 2008 Share Posted July 17, 2008 Maybe You can do it like this //include pages for any1 include('news.php'); include('about.php'); //include pages for logged users only if($user_is_loged==true) { include('usercp.php'); ... } Quote Link to comment https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-592600 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.