我有看法:
<?php echo form_open_multipart('search/item');?>
<input type='text' name='search' value="<?php echo set_value('search')?>">
<input type="submit" name="search_submit" value='Suchen'>
</form>
我的控制器看起来像但不起作用:
public function item($search=''){
if($search == '' && $this->input->post("search") != ""){
$search = urlencode($search);
header("Location:".site_url()."/search/item/$search");
}
$search = urldecode($search);
echo "suchen fur".$search;
}
如何通过url获取搜索文本的控制器,如mysite.com/search/item/search+text并显示结果?
答案 0 :(得分:0)
您使用URI Class
$search_term = $this->uri->segment(3);
// for mysite.com/search/item/search+text
// $search_term would be "search text"
答案 1 :(得分:0)
$this->load->helper('url');
$search_term = $this->uri->segment(3);
redirect("/search/item/" . $search_term);