Reputation: 492
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
Upvotes: 0
Views: 923
Reputation: 1401
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
Upvotes: 2