简单搜索:使用CodeIgniter将表单变量传递给URI [英] Simple Search: Passing Form Variable to URI Using CodeIgniter
本文介绍了简单搜索:使用CodeIgniter将表单变量传递给URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在每个页面上都有一个搜索表单。如果使用表单助手,则默认为 $ _ POST
。我希望搜索字词显示在URI中:
I have a search form on each of my pages. If I use form helper, it defaults to $_POST
. I'd like the search term to show up in the URI:
http://example.com/search/KEYWORD
我在Google上待了大约一个小时,但无济于事。由于本机URI约定,我仅找到有关基本上如何禁用 $ _ GET
的文章。我不能成为第一个想要这种功能的人,对吗?
I've been on Google for about an hour, but to no avail. I've only found articles on how $_GET
is basically disabled, because of the native URI convention. I can't be the first person to want this kind of functionality, am I? Thanks in advance!
推荐答案
如果您要与未启用JS的人打交道,那就有更好的解决方法。
There's a better fix if you're dealing with people without JS enabled.
视图:
<?php echo form_open('ad/pre_search');?>
<input type="text" name="keyword" />
</form>
控制器
<?php
function pre_search()
{
redirect('ad/search/.'$this->input->post('keyword'));
}
function search()
{
// do stuff;
}
?>
我以前已经使用过很多次了。
I have used this a lot of times before.
这篇关于简单搜索:使用CodeIgniter将表单变量传递给URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文