Jump to content

Recommended Posts

Hello. sorry about all the questions  ;D

 

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

 

Link to comment
https://forums.phpfreaks.com/topic/114728-navigation-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-589964
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-590338
Share on other sites

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 ?

Link to comment
https://forums.phpfreaks.com/topic/114728-navigation-help/#findComment-590435
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.