1
While I wear that filter for real estate, everything goes well but at the time I refresh the page, the checkbox makes the search disappear. It undoes all the session
or at least gives an error in the filter that does not allow to continue recovering 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 code of the form fields 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 see right below
print_r($_SESSION)
that the system continues to return theíndices
ofarray $civil
but does not apply thechecked
.
Thank you :)
Inattention !!! I was inattentive, it is hunger :)
– Marcos Vinicius
Quite interesting the solution ... I’m learning a lot ... Thanks Bacco ...
– Marcos Vinicius