ホームページ  >  記事  >  バックエンド開発  >  关于CI教程create页面插入数据库的问题

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

WBOY
WBOYオリジナル
2016-06-06 20:37:541097ブラウズ

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

关于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

<code>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');
    }

}
</code>

这段代码我都是照抄的。

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

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

回复内容:

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

关于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

<code>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');
    }

}
</code>

这段代码我都是照抄的。

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

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

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

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。