I have the following code:
HTML:
<input name="dataInicio" type="text" class="form-control datepicker" placeholder="Data" maxlength="10" autocomplete="off" />
<input name="dataFim" type="text" class="form-control datepicker" placeholder="Data" maxlength="10" autocomplete="off" />
MySQL
'date' DATE NOT NULL,
PHP
$dataInicio = (isset($_POST['dataInicio'])) ? '2017-09-25' : date("Y-m-d", strtotime($_POST['dataInicio']));
$dataFim = (isset($_POST['dataFim'])) ? date("Y-m-d") : date("Y-m-d", strtotime($_POST['dataFim']));
And finally the test I'm doing to return the range of days I need:
PHP
SELECT date,time,resultCode,hostname,user,sites,qt_acessos,bytes
FROM tblResumo
WHERE
date >= '$dataInicio' AND
date <= '$dataFim'
But I have the return of ALL the records, regardless of the date entered in the application form! And what I do not understand is that by checking in the POST, the values entered for the date range are there correctly. I am printing the values as JSON, if this information is useful. Where am I going wrong? I anticipate my thanks.