[eluser]Vasi[/eluser]
Hi,
I have a form with 3 inputs (1 text, 2 drop-downs). I have no problem performing the search and in displaying the pagination, the problem is in storing my POST values, on which the search query is based.
If I store them in the session, I keep getting the same result (of course) or nothing at all. So the questions is this:
How do I reset the session variables after I complete my search?
Or: If the session doesn't do the trick on storing the POST values, how should I rebuild my search module.
View
Code:
<?php
$cauta = array(
'name' => 'cauta',
);
$submit = array(
'name' => 'search_button',
'value' => 'Cauta'
);
$path = 'search';
?>
<?=form_open($path);?>
<label><strong>Cauta:</strong>
<?=form_input($cauta);?></label>
<label><strong>Oras:</strong>
<?=$localitati_search?> </label>
<label><strong>Categorie:</strong>
<?=$categorii_search?> </label>
<label>
<?=form_submit($submit)?> </label>
<?=form_close();?>
Controller
Code:
...
if($this->input->post('localitate'))
{
$search_sess_loc = array(
'search_loc' => $this->input->post('localitate')
);
$this->session->set_userdata($search_sess_loc);
}
if($this->input->post('categorie'))
{
$search_sess_cat = array(
'search_cat' => $this->input->post('categorie')
);
$this->session->set_userdata($search_sess_cat);
}
if ($this->session->userdata('search_loc'))
$localitate = $this->session->userdata('search_loc');
else
{
$localitate = 0;
}
if ($this->session->userdata('search_cat'))
$categorie = $this->session->userdata('search_cat');
else
{
$categorie = 0;
}
if ($this->session->userdata('search_term'))
$search_term = $this->session->userdata('search_term');
else
{
$search_term = '';
}
...