I'm trying to get the value of select
in $_SESSION
to persist the search data on a system I'm doing, but I do not know how to apply this method to select
. Can you help me?
I will save the variables after $_POST
...
<?php
if($_POST) {
$_SESSION['nome'] = $_POST['nome'];
}
?>
How do I save
select
as well as savedinput
?
<?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>