首页 > 关于CI教程create页面插入数据库的问题

关于CI教程create页面插入数据库的问题

教程地址(http://codeigniter.org.cn/user_guide/tutorial/create_news_items.html)
为什么我点击Create news item URL会变成
http://test.com/index.php/news/test.com/index.php/news/create?然后显示404

public function create()
{
    $this->load->helper('form');
    $this->load->library('form_validation');

    $data['title'] = 'Create a news item';

    $this->form_validation->set_rules('title', 'Title', 'required');
    $this->form_validation->set_rules('text', 'text', 'required');

    if ($this->form_validation->run() === FALSE)
    {
        $this->load->view('templates/header', $data);
        $this->load->view('news/create');
        $this->load->view('templates/footer');

    }
    else
    {
        $this->news_model->set_news();
        $this->load->view('news/success');
    }

}

这段代码我都是照抄的。

按正常应该他要运行else那部分,但是不知道为什么运行不了。
还有那个URL也很诡异。
如果他if判断语句成立应该也是load那个view模板,也就是原本这个页面吧?
为什么他会在URL后面直接追加一段URL?

在config/config.php里面将$config['base_url']设置为空已解决了。


看看你的代码里有没有什么重定向之类的东西!

【热门文章】
【热门文章】