On a codeigniter installation, I am trying to use the inbuilt $this->input->post(\'some_data\')
function, however $this->input->post()
Upgrading from 2.2.x to 3.0.x -- reason post method fails. If you are upgrading CI 3.x, need to keep the index_page in config file. Also check the .htaccess file for mod_rewrite. CI_3.x
$config['index_page'] = ''; // ci 2.x
$config['index_page'] = 'index.php'; // ci 3.x
My .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Finally got the issue resolved today. The issue was with the .htaccess
file.
Learning to myself: MUST READ THE CODEIGNITER DOCUMENTATION more thoroughly.
To use $this->input->post()
initialize the form helper. You could do that by default in config.
Change your form action,
From this:
<form method="post" action="<?=base_url()?>yourprocess">
Into this:
<form method="post" action="<?=base_url()?>index.php/yourprocess">
Basically, you just need to add "index.php" after your base_url():
action="http://www.yourdomain.com/index.php/yourprocess"
My issue was with an ajax call. I was using this:
type: 'posts',
instead of
type: 'post',
Syntax, D'oh!
Solved as follows:
Does the following exclude the redirection that is .htacess that will run the $ this-> input- > post ('name' ) on the controller, in my case it worked perfectly .
abs, José Camargo]