dtx3006 2013-01-25 20:19
浏览 62
已采纳

Codeigniter表单提交

So I'm rather new to Codeigniter... I have a file on my local host that submits a form:

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

From what I understand is that when I hit submit on the form, it goes to the function "form_validate()"(or whatever you set at the submission page) in the controller and executes that.

The Code works just fine on my localhost, however once I upload it to my live server, instead of going to the function in the controller it looks for a page called form_validation(at least thats what I think from the URL)

I've rewritten my base path as:

    $config['base_url'] = 'http://mysite.com/ci_form';

And gotten rid of the index.php under index I've also taken the Codeigniter mod_rewrite form their site

 <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
  • 写回答

1条回答 默认 最新

  • douluo3256 2013-01-25 20:29
    关注

    You're missing your controller in the form_open("form_validate"); function, that's why it's looking for a controller called form_validate.

    It needs to be form_open("your_controller_name/form_validate");

    http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

    Also your forms should be in your views

    Maybe this will help

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?