Confused with menues system

0

I tell you that I am a bit confused about a menu system that I am implementing in my web application. The subject is like this:

1) I have an index page that includes a header and a basic menu that points to several pages (put the names A, B and C for example). In this basic menu the option of entering the system is also included.

2) When the user enters or registers goes to a destination page, a landing page and the menu reacts according to the type of user that entered. The landing page is like the index but includes this new menu.

3) This destination page also has links to those pages A, B and C that could be accessed from the index ... therefore the menu should react according to the logged in user.

<?php
session_start(); //Iniciar una nueva sesión o reanudar la existente

require 'includes/conexion.php';
include 'includes/funcs.php';

if(isset($_SESSION["id_usuario"])){ //En caso de existir la sesión redireccionamos
    // Está logueado cargo el menú que sería para el tipo de usuario
} else{
    // No está logueado cargo el menú basico
}
?>

My query is: assuming that I do this in the index directly, will it work (I have not tried yet)? that is, without needing to "duplicate" the destination page, could you also apply it to the rest of the "n" pages?

Question aside, all the post I have in the different forms, should I always process them in separate php files?

I already thank you in advance for the help you can give me ...

I'm having some problem since in the login form I do a session_star () because I analyze if the user is logged in and I have to do if or if a session_start ()

session_start(); //Iniciar una nueva sesión o reanudar la existente
require 'includes/conexion.php';
include 'includes/funcs.php';

 if(isset($_SESSION["id_usuario"])){ //En caso de existir la sesión redireccionamos
    header("Location: 1908index.php");
 }

(page 1908index.php is the final index of the page)

Below, in the body cargo menu:

<?php
  include 'menu.php';
?> 

but in the menu.php I also have to handle session variables so I have to do another session_start () because if I do not, everything I have ignores it !!! ... How would I have to do?

//session_start(); //Iniciar una nueva sesión o reanudar la existente  
//require 'includes/conexion.php';
//include 'includes/funcs.php';
include_once("includes/analyticstracking.php");

if(isset($_SESSION["id_usuario"])){ 
  if($_SESSION['tipo_usuario']==1) { ?>

etc etc etc I finished commenting the lines of session_start () because it throws me an error that the session is already started, but still ignores everything that is below ...

    
asked by MNibor 29.06.2017 в 15:22
source

0 answers