1
Good , I have a page with form that contains some data that I show users, so when you search it changes page. I wanted the information that the user was searching to be "saved" in case he wanted to take that information to Excel , do not have to put the search information again. Follow my code for better viewing .
Php query.
<?php include("cabecalho_sg.php")?>
<br>
<!-- ##### Breadcrumb Area Start ##### -->
<div class="mag-breadcrumb py-3">
</div>
<!-- ##### Breadcrumb Area End ##### -->
<div class="container">
<form method="post" action="result_sg.php">
<div class="row align-items-center justify-content-center">
<div class="row align-items-center justify-content-center">
<b>Filial:     </b>
<select name="estado_inicial" id="estado_inicial">
<option value="1">Bahia</option>
<option value="2">São Paulo</option>
<option value="3">Rio de Janeiro</option>
</select>
  até  
<select name="estado_final" id="estado_final">
<option value="1">Bahia</option>
<option value="2">São Paulo</option>
<option value="3">Rio de Janeiro</option>
</select>
      <b>Data:</b>  
<input type="date" id="data_inicio" name="data_inicial">   até  
<input type="date" id="data_final" name="data_final">    
<button type="submit">  Consultar   </button> 
</div>
</div>
</form>
</div>
<br>
<!-- ##### Breadcrumb Area End ##### -->
<?php include("rodape.php")?>
php result.
<?php
define('DB_HOST' , "");
define('DB_USER' , "");
define('DB_PASSWORD' , "");
define('DB_NAME' , "");
define('DB_DRIVER' , "");
require_once "Conexao.php";
try{
//inicia a conexão
$Conexao = Conexao::getConnection();
$filial_inicial = $_POST['estado_inicial'];
$filial_final = $_POST['estado_final'];
$data_inicial = $_POST['data_inicio'];
$data_final = $_POST['data_final'];
//faz a consulta na tabela procurando palavras do form
$query = $Conexao->query ("EXEC PROCEDURE '$data_inicial','$data_final','$filial_inicial','$filial_final'");
$teste = $query->fetchAll();
}catch(Exception $e){
echo $e->getMessage();
exit;
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<?php
// A sessao precisa ser iniciada em cada página diferente
if (!isset($_SESSION)) session_start();
$setor_necessario = 55;
// Verifica se nao há a variável da sessao que identifica o usuário
if (!isset($_SESSION['email']) OR ($_SESSION['nivel'] != $setor_necessario) ) {
// Destrói a sessao por segurança
session_destroy();
// Redireciona o visitante de volta pro login
header("Location: index.php");
exit;
}
?>
<meta charset="UTF-8">
<meta name="description" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- Title -->
<title>Central de Relatorios | Moinho Canuelas</title>
<!-- Favicon -->
<link rel="icon" href="img/ll.ico">
<!-- Stylesheet -->
<link rel="stylesheet" href="style_busca.css">
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.quicksearch/2.3.1/jquery.quicksearch.js"></script>
</head>
<body>
<!-- Preloader -->
<div class="preloader d-flex align-items-center justify-content-center">
<div class="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</div>
<!-- ##### Header Area Start ##### -->
<header class="header-area">
<!-- Navbar Area -->
<div class="mag-main-menu" id="sticker">
<div class="classy-nav-container breakpoint-off">
<!-- Menu -->
<nav class="classy-navbar justify-content-between" id="magNav">
<!-- Nav Content -->
<div class="nav-content ">
<table>
<tr>
<th scope="col">
<form method="post" action="result_sg.php">
<b>Filial:     </b>
<select name="estado_inicial" id="estado_inicial">
<option value="1">Bahia</option>
<option value="2">São Paulo</option>
<option value="3">Rio de Janeiro</option>
</select>
  até  
<select name="estado_final" id="estado_final">
<option value="1">Bahia</option>
<option value="2">São Paulo</option>
<option value="3">Rio de Janeiro</option>
</select>
       
<label for="date">Data </label>
<input type="date" id="data_inicio" name="data_inicio"> até
<input type="date" id="data_final" name="data_final">    
<button type="submit">  Consultar   </button> 
<button type="submit" formaction="excel.php">  Gerar Excel   </button>
<button type="submit" formaction="inicio.php">  Voltar   </button>
                   
<input name="consulta" id="txt_consulta" placeholder="Digite para Pesquisar" type="text">
</th>
</tr>
</form>
</table>
</div>
<!-- Nav brand -->
<a href="inicio.php" class="nav-brand"><img src="img/logo.png" alt=""></a>
</nav>
</div>
</div>
</header>
<!-- ##### Header Area End ##### -->
<div class="table-responsive">
<table id="tabela" class="table-bordered">
<thead>
<tr>
<th scope="col">
<center><b>Filial</b></center>
</th>
<th scope="col">
<center><b>Entrega</b></center>
</th>
</tr>
</thead>
<?php
foreach($teste as $CLIENTE) {
?>
<tr>
<td>
<center>
<?php echo $CLIENTE['FILIAL']; ?>
</center>
</td>
<td>
<center>
<?php echo $CLIENTE['ENTREGA']; ?>
</center>
</td>
</tr>
<?php
}
?>
</table>
<?php include("rodape.php")?>
That is, the person is redirected to a page with results , however I would like the parameters that she did the search to be saved so that if she wants to click on generate excel do not have to put the parameters again.