3
I’m trying to get the value of select
in the $_SESSION
to persist the search data on a system I’m doing, but I don’t know how to apply this method to the select
. Can you help me?
I’ll save the variables after the $_POST
...
<?php
if($_POST) {
$_SESSION['nome'] = $_POST['nome'];
}
?>
How to save the
select
just as I kept theinput
?
<?php
if(isset($_SESSION['nome'])){
echo '<input type="text" name="nome" value="'.$_SESSION['nome'].'" class="form-control">';
} else {
echo '<input type="text" name="nome" value="" class="form-control">';
}
?>
<select name="tipo" class="form-control" required>
<option value="">Tipo</option>
<option value="apartamento">Apartamento</option>
<option value="casa">Casa</option>
<option value="flat">Flat</option>
</select>
That’s exactly it !!!! The paths of the other answer helped me to get where I wanted. Thank you.
– Marcos Vinicius
I thought Alisson’s explanation was good, but I had the impression that his question was more about select than about Session.
– Bacco
I will ask this question to checkbox ... help me Bacco ... Thank you !!!
– Marcos Vinicius
I misread the term ... it’s checkbox because it involves array and selection of various elements ... so I want to reproduce this question to checkbox. What do you think?
– Marcos Vinicius