$ this-> input-> post()为空,而在Codeigniter中设置了$ _POST

时间:2014-01-13 08:08:09

标签: forms codeigniter post

我在codeigniter中遇到问题,我尝试通过这种形式通过帖子发送表单数据:

    <form action="http://localhost/Bookstore/index.php/cart/add/1" method="post">
        <input id="url" name="url" type="text" value="http://localhost/Bookstore/index.php/book/id/1" class="hidden">
        <button class="btn btn-primary" type="submit">
            <i class="fa fa-shopping-cart"></i> In den Warenkorb
        </button>
    </form>

但是,当我尝试访问$this->input->post('url')时,$this->input->post()不包含任何内容,$_POST包含我需要的数据(url)。

任何想法如何解决这个问题?我想避免使用$ _POST,因为在codeigniter中没有建议读取它。

2 个答案:

答案 0 :(得分:0)

尝试在CI中的config.php文件中更改此内容

 $config['uri_protocol'] = "REQUEST_URI";  

并改变

$config['index_page'] = 'index.php';

在config.php中

$config['index_page'] = '';

答案 1 :(得分:0)

尝试准确地说

action="/Bookstore/index.php/cart/add/1"

它应该有用。

出于某些原因,我认为 .htaccess + CI 控制器配置你需要准确地填写该网址