Codeigniter $this->input->post() empty while $_POST is working correctly Codeigniter $this->input->post() empty while $_POST is working correctly codeigniter codeigniter

Codeigniter $this->input->post() empty while $_POST is working correctly


You can check, if your view looks something like this (correct):

<form method="post" action="/controller/submit/">

vs (doesn't work):

<form method="post" action="/controller/submit">

Second one here is incorrect, because it redirects without carrying over post variables.

Explanation:

When url doesn't have slash in the end, it means that this points to a file.

Now, when web server looks up the file, it sees, that this is really a directory and sends a redirect to the browser with a slash in the end.

Browser makes new query to the new URL with slash, but doesn't post the form contents. That's where the form contents are lost.


Try This, change

$config['base_url'] = 'http://mywebsite.cl/';

to

$config['base_url'] = 'http://www.mywebsite.cl/';

Some provider auto add www , https , etc to your url, most of the times, this causes this issue


To use $this->input->post() initialize the form helper. You could do that by default in config.