1
On my website, I have a part of the code where two checkbox options should be shown for the check-in date case with difference greater than or equal to 72 hours (or 3 days) compared to today.
<?php
$difdias = (1/86400)*(strtotime($_SESSION['buscaReserva']['dataInicio'])-strtotime(date('Y-m-d')));
if(($_REQUEST['idHotel'] == '373443') && ($difdias >= 3)) {
echo "<tr><td><div id='chkDolars' name='valueDolars' class='checkbox chkSelecionado' style='margin-bottom: 10px'><span class='ph03_105'></span></div><div id='chkReais' name='valueReais' class='checkbox' style='margin-bottom: 10px'><span class='ph03_103'></span></div></td>";
echo "<td><div id='msgReais'><span id='lblReais' class='ph03_104' style='display: none'></span></div></td></tr>";
//echo $_SESSION['buscaReserva']['dataInicio'];
}
?>
At first, everything is OK, but if I first do a search with check-in greater than 3 days and then do another with check-in less than 3 days, then appear the checkboxes, However, if I repeat this search in the sequence, then the checkboxes disappear (and they should have disappeared the previous time). The same happens if the first search is with check-in less than 3 (there are no checkboxes), I do a second search with check-in greater than 3 and there are no checkboxes and, repeating this second search, end up appearing (when they should have appeared the previous time).
In the commented line of the code, I decided to check how it is coming the variable $_SESSION['buscaReserva']['dataInicio']
. I think it takes time to update, and updating the page in new search is usually quick.
I’m not sure how clear the situation is. What I could do in this case to only see the checkboxes in the correct situation (check-in date greater than 3 days) and disappear in the correct situation (check-in date less than 3 days)?
Where you declare the variable $_SESSION['searchReserva']['startData'] ??
– Hiago Souza
after <?php tried to put session_start Ex: <?php session_start();
– Hiago Souza
I imagine this should be solved on the front end, right? With jquery or pure javascript...
– Felipe Avelar
No, javascript/jquery are not server language so they cannot manage sessions
– Hiago Souza