• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
POST data not being sent from a form to a controller

#11
[eluser]CroNiX[/eluser]
Try different settings for
Code:
$config['uri_protocol']
in
/application/config/config.php

You could also try putting a print_r($_POST); at the top of your index.php file to see if post is making it through before CI gets ahold of it.

#12
[eluser]Rurik[/eluser]
[quote author="CroNiX" date="1350254736"]Try different settings for
Code:
$config['uri_protocol']
in
/application/config/config.php

You could also try putting a print_r($_POST); at the top of your index.php file to see if post is making it through before CI gets ahold of it.[/quote]

This makes no sense to me, though in the first case that would be because I dont understand how the uri_protocol option affects things.

but the print_r in the index makes no sense, as other pages can handle post data, just not this one and one other for some reason. Especially seeing as how all of this is behind CI's front door so to speak.

Again, this could be me not understanding how CI does things.

#13
[eluser]CroNiX[/eluser]
Where exactly are you checking to see if you lost your post data? Early on in your update method, you check if the form was submitted and if it was you redirect just after updating (some) of your data in your model. Redirecting wipes out the POST array (new request to server) so if you're trying to access it after the redirect you can't.

Also, you shouldn't be using $_POST directly, use $this->input->post('field')

#14
[eluser]Rurik[/eluser]
not to be rude, but if you read through the code, you would notice that I check the post before the redirect, and that it cant get into the earlier redirect, because post is empty, which means submit is not set. You would also note that I dont use $_POST directly, and that I do use $this->input->post('field');

I only used $_POST for testing if the array was there at all, via var dump

#15
[eluser]CroNiX[/eluser]
Ah, I must have imagined this line while I wasn't reading through your convoluted code:
Code:
if (isset($_POST['submit']))
I'll leave you to it - sorry to bother you.

#16
[eluser]Rurik[/eluser]
oh, that one instance, my mistake. As I said, this is not my original code, but code I have been tasked with extending. This is, as far as I know, the only time this is used in the controllers, and either way it does not get into there in the first place and is so not the cause of the problem.

#17
[eluser]Rurik[/eluser]
However, after following your suggestion to change it, as expected, no change, because the problem is not that submit isnt being posted, but that nothing seems to be posted, though if my guess of how form helper works, the equivalent of onsubmit is working.

#18
[eluser]TWP Marketing[/eluser]
No better suggestion on the problem, but which version of CI is being used here?

#19
[eluser]Rurik[/eluser]
2.0.2, on ubuntu 12.04

#20
[eluser]TWP Marketing[/eluser]
Ok, I'm using 2.1.2-3 under Ubuntu 12.04 myself.
I've looked through the User Guide change log (http://ellislab.com/codeigniter/user-gui...gelog.html) and found these:

Ver. 2.0.3
form_open() now only adds a hidden (Cross-site Reference Forgery) protection field when the form's action is internal and is set to the post method. (Reactor #165)

Ver. 2.1.1
Fixed a bug - form_open() compared $action against site_url() instead of base_url()

The second bug fix (2.1.1) may effect your situation, however, your code does call and execute the update controller method, which says (to me at least) that the path is correct.

The first bug fix (2.0.3) doesn't appear to apply to your case, but I note in just in case.

I recall that there were a number of problems with version 2.0.2, which prompted version 2.0.3 and above.
Look at the change log and see if you recognize anything.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.