codeigniter form POST Empty in Controller from View codeigniter form POST Empty in Controller from View codeigniter codeigniter

codeigniter form POST Empty in Controller from View


It could be a .htaccess issue with RewriteRule, according to this CI github post issue https://github.com/bcit-ci/CodeIgniter/issues/242:

if Apache server is used then mod rewrite should be enabled, otherwise redirection will be proper but with empty $_POST.

&

if you don't have a trailing slash on your URL the server will send a 301 redirect which will interfere with POST data.

Your problem could be with

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Try changing to:

RewriteRule ^(.*)$ index.php/$1 [PT,L]

(from: not able get post form submit values in codeigniter) or try to set:

sudo a2enmod rewrite

Hope it helps!


Hi as par my research about this problem is a very unacceptable type but yet I don't know why this is happening or maybe in Codeigniter have some restriction for this kind of problem.

if you described your base URL in config like this, remember at last of URL not included slash:

http://ip/free/index.php

and on your HTML file on the form tag at the action described like this. remember at last used slash:

http://ip/free/index.php/taskdetails/tabOne/1/ShibNo/asc/

This is occurring problem to not pass any data to the controller because 'slash' change the path.

In this case, if you did not use a slash at last on-base URL then don't use on HTML form also to make it work.

If you face this kind of problem then once try this might help.


I was with the same error and solve like the answer above.

baseURL in the .env file must contain for production something like

https://www.yourwebsite.com.br/CodeIgniter 4