所以我对Codeigniter很新... 我的本地主机上有一个提交表单的文件:
$id =array('id' => 'commentForm');
echo form_open("form_validate", $id);
public function form_validate()
{
$this->load->library("form_validation");
$this->form_validation->set_rules('date', 'Date', 'required');
$this->form_validation->set_rules('Cname', 'Client Name', 'required');
....
}
据我所知,当我在表单上点击提交时,它会转到控制器中的“form_validate()”函数(或者你在提交页面设置的任何内容)并执行它。
Code在我的本地主机上运行得很好,但是一旦我将它上传到我的实时服务器,而不是转到控制器中的函数,它会查找一个名为form_validation的页面(至少这就是我从URL中看到的)< / p>
我已将我的基本路径重写为:
$config['base_url'] = 'http://mysite.com/ci_form';
在索引下摆脱了index.php 我还把Codeigniter mod_rewrite形成了他们的网站
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_form/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
答案 0 :(得分:2)
你错过了form_open("form_validate");
函数中的控制器,这就是为什么它正在寻找一个名为form_validate的控制器。
需要form_open("your_controller_name/form_validate");
http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html
此外,您的表单应该在您的观点中
也许this会有所帮助