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

[eluser]Mitja B.[/eluser]
is it possible to get value from array with $this->input->post() function or i need standsrd $_POST[][] function.

Thx
#2

[eluser]Michael Wales[/eluser]
The version of CI currently in the SVN repository will allow you to retrieve a value from an array.
#3

[eluser]orokusaki[/eluser]
HOW?

If I try to do this:

Code:
$post = $this->input->post();

echo '&lt;html&gt;&lt;body><p>Here they are</p><p>';

foreach($post as $key => $value)
{
    echo $key . '=' . $value;
}

echo '</p>&lt;/body&gt;&lt;/html>';

I get a big nasty back, or if I do this:

Code:
foreach($this->input->post() as $key => $value)
{
    echo $key . '=' . $value;
}

What am I doing wrong?
#4

[eluser]OES[/eluser]
Hi orokusaki

CI 1.6.3 does not handle post arrays very well at all.

I suggest you either try out 1.7 from the SVN. Or the is a extension for it in the Wiki:

Assosiative Arrays via POST

This has worked really well for me in past ci sites.

Hope this helps.

Lee
#5

[eluser]orokusaki[/eluser]
Sweet, thanks for the quick reply. One question though, is 1.7 ok for production use?

Here's my temporary solve for those using 1.6.3 who would still like the benefits of using the OOP version of accessing the values:

Code:
if($_POST)
        {
            foreach($_POST as $k => $v)
            {
                echo 'Key = ' . $k . '<br /> Value = ' . $this->input->post($k) . '<br /><br />';
            }
        }
#6

[eluser]OES[/eluser]
Some people are using it I believe in prodoction sites.

I myself have just started testing it so I am not in the best position to give you an answer.

Good luck.

Lee
#7

[eluser]xwero[/eluser]
Michael was wrong with his statement that the input->post method can retrieve specific array values based on a key, or he is working with a version that hasn't seen daylight yet Wink

I wouldn't use 1.7 because they are changing things on a regular basis. Some of those changes can be the cause of new or resurfacing bugs.

If you use the global xss filter you can safely use the php native $_POST[] syntax.
#8

[eluser]Thorpe Obazee[/eluser]
[quote author="xwero" date="1224678116"]Michael was wrong with his statement that the input->post method can retrieve specific array values based on a key, or he is working with a version that hasn't seen daylight yet Wink

I wouldn't use 1.7 because they are changing things on a regular basis. Some of those changes can be the cause of new or resurfacing bugs.

If you use the global xss filter you can safely use the php native $_POST[] syntax.[/quote]

Yep and it's better to build something on the stable version.
#9

[eluser]orokusaki[/eluser]
Quote:Yep and it's better to build something on the stable version.

Wowsers, I didn't know that the actual $_POST array was cleaned, but upon further investigation I found this:

line# 140 of Input.php
Code:
$_POST = $this->_clean_input_data($_POST);

Earlier in the class in the function _clean_input_data() the $_POST array is emptied for this new data.




Theme © iAndrew 2016 - Forum software by © MyBB