I have two files
ExportDatos.php I have a form, where I enter the name of the executive and the date range
<div class="col-md-6">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">Ingrese los Datos:</h3>
</div>
<div class="box-body">
<!-- Date -->
<div class="form-group">
<label>Ejecutivo:</label>
<select id ="ejecutivo" name ="ejecutivo" class="form-control select2" type = "text" style="width: 100%;">
<option value ="0">Seleccione:</option>
<?php
$queryEje = "select nom_ejecutivo as nombre, apaterno_ejecutivo as apellido from ejecutivos_afa where estado = '1' and id_tipo = '2';";
$resultadoEje = mysqli_query($cn, $queryEje);
while ($valores = mysqli_fetch_array($resultadoEje)){
$eje = $valores['nombre'] .' '. $valores['apellido'];
$id_eje = $valores ['id'];
echo '<option value = "'.$id_eje.'"> '.$eje.' </option>';
}
?>
</select>
</div>
<!-- /.form group -->
<!-- Date range -->
<div class="form-group">
<label>Fecha Inicio:</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input id="datepicker" name="datepicker" type="text" class="form-control" value="">
</div>
<div id="errorDatepicker"></div>
<!-- /.input group -->
</div>
<div class="form-group">
<label>Fecha Fin:</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input id="datepicker1" name="datepicker1" type="text" class="form-control" value="">
</div>
<div id="errorDatepicker"></div>
<!-- /.input group -->
</div>
<div align="right">
<div class="btn-group">
<input type="submit" name="enviarexportar" id="enviarexportar" value="Exportar" class="btn btn-info" onmouseover="validarExportar();"/>
<input type="reset" name="cancelarsolicitud" id="cancelarsolicitud" class="btn btn-default" value="Cancelar" />
</div>
</div>
</div>
<!-- /.box-body -->
</div>
</div>
I have another ExportExcel file, where I receive by the method $ _POST the options entered
<?php
date_default_timezone_set('America/Santiago');
session_start();
include('../../../conexion/index.php');
require ("PHPExcel.php");
//Cabeceras de la Libreria de PHPExcel
header('Content-type: application/vnd.ms-excel;charset=iso-8859-15');
header('Content-Disposition: attachment; filename=Informacion_Ejecutivo.xls');
$id_eje = $_POST["ejecutivo"]; // Esta variable me llega vacio, por tal motivo no me ejecuta la sentencia SQL
$fecha_ini = $_POST["datepicker"];
$fecha_fin = $_POST["datepicker1"];