跳转到主内容
websoft网络软件专家 - 深耕网络技术,打造实用软件!

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

PHP 8.5.5 PHP 8.5.5 是 PHP 8.5 分支的维护更新版本。该版本延续了“小步快跑”的迭代逻辑,通过深度错误修复、底层性能微调以及安全加固,旨在为开发者提供一个更健壮、更高效的运行环境。该版本严格遵守语义化版本规范,不包含破坏性变更。 下载 教程地址(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']设置为空已解决了。 回复内容: 教程地址(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']设置为空已解决了。 看看你的代码里有没有什么重定向之类的东西!

相关文章