Boa tarde pessoal, sou iniciante da área e estou tendo a dificuldade em deixar o menu do sidebar aberto, na verdade não sei como fazer.
Quando é tudo na mesma pagina ok, usa o tag class=active funciona normal.
mas como fazer isso chamando header.php e footer.php .
Segue as paginas que utilizo
pagina header.php
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>GAP</title>
<link rel="icon" href="imagem/favicon.ico">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script defer src="js/fontawesome-all.min.js"></script>
<link rel="stylesheet" href="css/fontawesome.min.css">
<link rel="stylesheet" href="css/dashboard.css">
</head>
<body>
<!------------------- navbar --------------------------->
<nav class="navbar navbar-expand navbar-dark bg-primary">
<a class="sidebar-toggle text-light mr-3">
<span class="navbar-toggler-icon"></span>
</a>
<a class="navbar-brand" href="#">GAP</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle menu-header" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown">
<img class="rounded-circle" src="imagem/icon.png" width="20" height="20"> <span class="d-none d-sm-inline">Usuário</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#"><i class="fas fa-user"></i> Perfil</a>
<a class="dropdown-item" href="logout.php"><i class="fas fa-sign-out-alt"></i> Sair</a>
</div>
</li>
</ul>
</div>
</nav>
<!------------------- Menu sidebar --------------------------->
<div class="d-flex">
<nav class="sidebar">
<ul class="list-unstyled">
<li><a href="#"><i class="fas fa-tachometer-alt"></i> Dashboard</a></li>
<li>
<a href="#submenu1" data-toggle="collapse">
<i class="fas fa-user"></i> Usuário
</a>
<ul id="submenu1" class="list-unstyled collapse">
<li><a href="usuario_cadastrar.html"><i class="fas fa-user-plus"></i> Novo </a></li>
<li><a href="usuario_listar.php"><i class="fas fa-users"></i> Usuários </a></li>
</ul>
</li>
<li>
<a href="#submenu2" data-toggle="collapse"><i class="fas fa-list-ul"></i> Produtos</a>
<ul id="submenu2" class="list-unstyled collapse">
<li><a href="#"><i class="fas fa-tags"></i> Cadastrar</a></li>
<li><a href="#"><i class="far fa-list-alt"></i> Listar </a></li>
</ul>
</li>
<li>
<a href="#submenu3" data-toggle="collapse"><i class="fas fa-folder"></i> Categoria</a>
<ul id="submenu3" class="list-unstyled collapse">
<li><a href="#"><i class="fas fa-folder-plus"></i> Cadastrar</a></li>
<li><a href="#"><i class="fas fa-folder-open"></i> Listar </a></li>
</ul>
</li>
<li>
<a href="#submenu4" data-toggle="collapse"><i class="fas fa-truck"></i> Fornecedor</a>
<ul id="submenu4" class="list-unstyled collapse">
<li><a href="#"><i class="fas fa-tags"></i> Cadastrar</a></li>
<li><a href="#"><i class="far fa-list-alt"></i> Listar </a></li>
</ul>
</li>
<li><a href="logout.php"><i class="fas fa-sign-out-alt"></i> Sair</a></li>
</ul>
</nav>
pagina teste.php
<?php
include "header.php";
?>
<div class="content p-1">
<div class="list-group-item">
<div class="d-flex">
<div class="mr-auto p-2">
<h2 class="display-4 titulo">Cadastrar Usuário</h2>
</div>
</div>
<hr>
<form action="usuario_include.php" method="GET">
<div class="form-row">
<div class="form-group col-md-6">
<label><span class="text-danger">*</span> Nome</label>
<input name="nome" type="text" class="form-control" id="nome" placeholder="Nome Completo" required>
</div>
<div class="form-group col-md-6">
<label><span class="text-danger">*</span> E-mail</label>
<input name="email" type="email" class="form-control" id="email" placeholder="Seu e-mail" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label><span class="text-danger">*</span> Senha</label>
<input name="senha" type="password" class="form-control" id="senha" placeholder="A senha com mínimo de 6 caracteres" required minlength="6">
</div>
<div class="form-group col-md-6">
<label><span class="text-danger">*</span> Confirmação de Senha</label>
<input name="conf_senha" type="password" class="form-control" id="conf_senha" placeholder="Confirmar a senha" required required minlength="6">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label>Endereço</label>
<input name="endereco" type="text" class="form-control" id="endereco" placeholder="Rua João...">
</div>
<div class="form-group col-md-2">
<label>Número</label>
<input name="numero" type="text" class="form-control" id="numero" placeholder="123">
</div>
<div class="form-group col-md-4">
<label>Complemento</label>
<input name="complemento" type="text" class="form-control" id="complemento" placeholder="Sala, Apartamento">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-5">
<label>Estado</label>
<select name="estado" id="estado" class="form-control">
<option selected>Selecione</option>
<option>...</option>
</select>
</div>
<div class="form-group col-md-5">
<label>Cidade</label>
<select name="cidade" id="cidade" class="form-control">
<option selected>Selecione</option>
<option>...</option>
</select>
</div>
<div class="form-group col-md-2">
<label>CEP</label>
<input name="cep" type="text" class="form-control" id="cep" placeholder="xx.xxxx-xxx">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-2">
<label>Login</label>
<input name="login" type="text" class="form-control" id="login" placeholder="Insira um login" required>
</div>
<div class="form-group col-md-2">
<label>Nivel de Acesso</label>
<select name="nivel_acesso" id="nivel_acesso" class="form-control">
<option selected>"Selecione"</option>
<option value="1">Administrador</option>
<option value="2">Usuario</option>
</select>
</div>
<div class="form-check col-md-1 p-5">
<input class="form-check-input" name="status" type="checkbox" value="ativo" id="status">
<label class="form-check-label" for="defaultCheck1">
Ativo
</label>
</div>
<p>
</div>
<span class="text-danger">*</span> Campo Obrigatório
</p>
<button type="submit" class="btn btn-success">Cadastrar</button>
</form>
</div>
</div>
</div>
</div>
<!------------------- Modal para confirmar a exclusão de um registo--------------------------->
<div class="modal fade" id="apagarRegistro" tabindex="-1" role="dialog" aria-labelledby="apagarRegistro" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header bg-danger text-white">
<h5 class="modal-title" id="exampleModalLabel">Excluir item</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Tem certeza que deseja excluiir o item selecionado?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal">Cancelar</button>
<button type="button" class="btn btn-danger">Apagar</button>
</div>
</div>
</div>
</div>
<?php
include "footer.php";
?>