While I use this filter to search real estate, everything goes well but at the time I refresh the page, the checkbox causes the search to disappear. It undoes all session
or at least it gives an error in the filter that does not allow to continue to recover the other sessions
.
How can I improve this script so that the search is not undone by refreshing the page? I repeat, the checkbox is doing this.
$civil = [];
if(isset($_POST['busca-implacavel'])) {
if( isset( $_POST['tipo'] ) ) $_SESSION['tipo'] = $_POST['tipo'];
if( isset( $_POST['civil'] ) ) $_SESSION['civil'] = $_POST['civil'];
if( isset( $_POST['cidade'] ) ) $_SESSION['cidade'] = $_POST['cidade'];
if( isset( $_POST['valorminimo'] ) ) $_SESSION['valorminimo'] = $_POST['valorminimo'];
if( isset( $_POST['valormaximo'] ) ) $_SESSION['valormaximo'] = $_POST['valormaximo'];
$tipo = isset( $_SESSION['tipo'] ) ? $_SESSION['tipo'] : '';
$civil = isset( $_SESSION['civil'] ) ? $_SESSION['civil'] : '';
$cidade = isset( $_SESSION['cidade'] ) ? $_SESSION['cidade'] : '';
$valorminimo = isset( $_SESSION['valorminimo'] ) ? $_SESSION['valorminimo'] : '';
$valormaximo = isset( $_SESSION['valormaximo'] ) ? $_SESSION['valormaximo'] : '';
}
Here is the form field code related to checkbox
:
<input type="checkbox" name="civil[]" value="solteiro" <?php echo in_array("solteiro", $civil) ? " checked='checked'" : ""; ?>>Solteiro<br>
<input type="checkbox" name="civil[]" value="casado" <?php echo in_array("casado", $civil) ? " checked='checked'" : ""; ?>>Casado<br>
<input type="checkbox" name="civil[]" value="viuvo" <?php echo in_array("viuvo", $civil) ? " checked='checked'" : ""; ?>>Viúvo<br>
<input type="checkbox" name="civil[]" value="divorciado" <?php echo in_array("divorciado", $civil) ? " checked='checked'" : ""; ?>>Divorciado<br>
<input type="checkbox" name="civil[]" value="uniaoestavel" <?php echo in_array("uniaoestavel", $civil) ? " checked='checked'" : ""; ?>>União Estável<br>
You can repair it right below the%% of the system continues to return
print_r($_SESSION)
ofíndices
but does not applyarray $civil
.
Thank you:)