I have a form that posts a search query to my ‘search’ controller:
<div id="search_box">
<?php echo form_open('search'); ?>
<?php echo form_input('searchvalue', 'search...'); ?>
<?php echo form_submit('submit', 'Search!'); ?>
<?php echo form_close(); ?>
</div>
In my search controller I have the following code:
public function index()
{
$page = 'search';
$category = 'search';
if($this->input->post('searchvalue')) {
redirect('search/query');
};
......
}
My problem is that it won’t do the redirect. I have the form helper autoloaded. What can I do to solve this mystery. Is it a case for the batman?
In Codeigniter if you ask for a POST variable from the Input class it will return the value or FALSE if the value is empty (Personal Experience) or not found.
So Maybe instead put in a Hidden field with a Dummy value and just check for that on each submit. You can then perform validation and redirect. This will then work if the search query is provided or not.
And the
;after youifis not valid PHP.For Example:
Hope I understood that correctly.