Welcome Guest, Not a member yet? Register   Sign In
strange behaviour of input->post()
#1

[eluser]Soruman[/eluser]
Dear Codeigniter Community,

Today I've encountered something strange about input->post().

I am posting data using ajax to a Codeigniter page,

Using print_r ($_POST) returns data;
Even using print $this->input->post('KEY') returns data,
but $this->input->post() returns FALSE, like the post array is empty.

I was trying to use validation but couldn't be sucessfull. After struggling with the code a while, I tried this for debug and noticed this problem.

What can be the reason for it?

Thanks in advance,
#2

[eluser]InsiteFX[/eluser]
It only returns a value not an array! In which you are not specifing and item for $this->input->post('item');

InsiteFx
#3

[eluser]Soruman[/eluser]
Dear insiteFX,

Thanks for your quick reply.

The paragraph below is from Code Igniter User Guide;

"To return an array of all POST items call without any parameters.

To return all POST items and pass them through the XSS filter leave the first parameter blank while setting the second parameter to boolean;

The function returns FALSE (boolean) if there are no items in the POST."

Check it out here;
http://ellislab.com/codeigniter/user-gui...input.html

In my situation, there are items in the POST, but it returns false...
However If I call it with item_key, it returns the value... :S
#4

[eluser]Soruman[/eluser]
I still don't know why this happened, but updating to CI 2.02 resolved the problem with input->post()...
#5

[eluser]JonoB[/eluser]
[quote author="Soruman" date="1307334894"]I still don't know why this happened, but updating to CI 2.02 resolved the problem with input->post()...[/quote]
Quote:Input Class methods post() and get() will now return a full array if the first argument is not provided.
Was only added in 2.0.1
http://ellislab.com/codeigniter/user-gui...gelog.html




Theme © iAndrew 2016 - Forum software by © MyBB