CodeIgniter Forums
Empty $this->input->get_post in controller whereas $_POST has value at index.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forum-9.html)
+--- Thread: Empty $this->input->get_post in controller whereas $_POST has value at index.php (/thread-66213.html)



Empty $this->input->get_post in controller whereas $_POST has value at index.php - thewonder - 09-21-2016

Hi,

I am facing issue after setting up CodeIgniter 3.1.0 at my server, i.e. I am getting empty $this->input->get_post in my controller but I can get proper $_POST at index.php. Problem is $_POST also become empty in controller. Please guide me. Server is CentOS having plesk.

Best Wishes,
thewonder


RE: Empty $this->input->get_post in controller whereas $_POST has value at index.php - mwhitney - 09-26-2016

Have you tried $this->input->post() or $this->input->post_get()? I never use get_post() or post_get() myself, but the first step in troubleshooting an issue with either one would be to check the input method that only returns values from the correct array. If it shows up in $this->input->post(), but not $this->input->get_post(), this would imply that $_GET[$index] is set to an empty value.


RE: Empty $this->input->get_post in controller whereas $_POST has value at index.php - thewonder - 09-27-2016

Issue turned out to be from Apache's server settings. There were some conditional redirections to automatically move users to https, and once I removed that condition, codeigniter started working fine, web services were able to get post data properly. Although I'll have to find a way for moving users to https if incase they mistakenly use http..


RE: Empty $this->input->get_post in controller whereas $_POST has value at index.php - mwhitney - 09-28-2016

On one of my sites, I used this in the site's .conf file:

Code:
<VirtualHost *:80>
    ServerName my.server.name
    Redirect 301 / https://myserver.url.here/
</VirtualHost>

Since HTTP and HTTPS are on different ports, configuring port 80 to redirect to HTTPS works pretty well. Of course, this is probably the wrong status code and you probably want to handle things a little more elegantly, but it's a start. This is also intentionally driving all of the traffic to HTTPS, which may not be what you're looking for.

I found that supporting both and ensuring that HTTPS was used everywhere it should be was usually not worth the effort (compared to just pushing as much traffic as possible to HTTPS), and just setting the base URL on the site to use https:// significantly reduced the number of odd issues that would crop up.


RE: Empty $this->input->get_post in controller whereas $_POST has value at index.php - thewonder - 10-03-2016

(09-28-2016, 01:49 PM)mwhitney Wrote: On one of my sites, I used this in the site's .conf file:

Code:
<VirtualHost *:80>
   ServerName my.server.name
   Redirect 301 / https://myserver.url.here/
</VirtualHost>

Since HTTP and HTTPS are on different ports, configuring port 80 to redirect to HTTPS works pretty well. Of course, this is probably the wrong status code and you probably want to handle things a little more elegantly, but it's a start. This is also intentionally driving all of the traffic to HTTPS, which may not be what you're looking for.

I found that supporting both and ensuring that HTTPS was used everywhere it should be was usually not worth the effort (compared to just pushing as much traffic as possible to HTTPS), and just setting the base URL on the site to use https:// significantly reduced the number of odd issues that would crop up.

thank you mwhitney Smile