问题描述
首先,相关代码:
查看
< div id =search>
<?= form_open('sheet / search')?>
<?= form_input('search_query','','id =search_queryplaceholder =Search Sheet Music')?>
<?= form_submit('submit','Search!','class =hidden')?>
<?= form_close()?>
< / div>
控制器表/搜索
public function search()
{
if($ this-> input-> post('search_query'))
{
// blah
// [...]
<$
到底是什么?令人讨厌的是,其他形式在我的网站上工作完美。此外,这在我的测试服务器上完美工作...所以我猜,有一些东西,我的配置文件,.htaccess或者东西。但是,我不知道是什么原因造成的。
如果你有一个想法,需要更多的信息,请随时指定。我只是不知道在哪里看,或什么改变!
EDIT 1/8/2013
好吧,我做了一个发现。当我的索引页从 config / config.php 中删除时,搜索不工作。
它仍然没有任何意义。
下面是我的.htaccess文件。认为我需要修改它不知何故?我完全不知道为什么它不工作,但这是一个正确的方向一步。
RewriteEngine on
RewriteCond $ 1!^(index\.php | images | assets | sheet | robots\.txt)
RewriteRule ^(。*)$ /index.php/$1 [L]
AHA,我知道了!
这个问题很狡猾。显然,因为我的 .htaccess
文件除了工作表
目录,控制器有相同的名称,事情进行与CodeIgniter路径矛盾。什么,确切地,我不知道。
对于任何人,未来有这个问题...请确保您的 .htaccess
文件不会弄乱你的控制器!
First, relevant code:
View
<div id="search">
<?= form_open('sheet/search') ?>
<?= form_input('search_query', '', 'id="search_query" placeholder="Search Sheet Music"') ?>
<?= form_submit('submit', 'Search!', 'class="hidden"') ?>
<?= form_close() ?>
</div>
Controller sheet/search
public function search()
{
if ($this->input->post('search_query'))
{
// blah
// [ ... ]
$_POST
is completely empty.
What on earth? The annoying thing is, other forms work perfectly fine on my website. Furthermore, this works perfectly on my testing server... so I'm guessing there's something wonky with my configuration files, .htaccess, or something. However, I don't know what could be causing it.
If you have an idea and need more information, feel free to specify. I just have no idea where to look, or what to change! Any help would be hugely appreciated.
Thanks!
EDIT 1/8/2013
Okay, I made a discovery. When my index page is removed from config/config.php, the search does not work. However, when it is added, it DOES work.
It still doesn't make any sense.
Below is my .htaccess file. Think I need to modify it somehow? I have absolutely no idea why it's not working still, but this is a step in the right direction.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|sheet|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
AHA, I got it!
The problem was pretty sneaky. Apparently, because my .htaccess
file was excepting the sheet
directory, AND the controller had the same name, things were going screwy with the CodeIgniter paths. What, exactly, I don't know. But it was bad, apparently!
To anyone in the future with this problem... make sure your .htaccess
file isn't messing with your controllers!
这篇关于CodeIgniter $ _POST数据为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!