$_POST empty

$_POST empty

Posted by: leischj
Posted on: 2009-08-26 07:55:00

I have a page that posts form values to another page that worked in January, and doesn't work anymore. It hasn't been used since January, now it needs to be used again. No code had changed, and a search led me to believe that I needed to change my $HTTP_POST_VARS to $_POST. I did this, and now the $_POST array comes empty.

What's really strange to me is that if I output $_REQUEST, I get everything that I would expect, all my $_GET, $_POST, and $_COOKIE, as the documentation suggests. But then I output each of $_GET, $_POST, and $_COOKIE separately, and the $_POST is empty. The other two are correct.

For now I will use $_REQUEST since it has all my posted values. Is there a setting that I need to change to make the $_POST variable work?

Re: $_POST empty

Posted by: Atropos7
Posted on: 2009-08-26 10:09:00

In reply to:

For now I will use $_REQUEST since it has all my posted values. Is there a setting that I need to change to make the $_POST variable work?


First things first - let's check the value of $_SERVER['REQUEST_METHOD'] because if it is not 'POST' we should expect $_POST to be empty.

In reply to:

What's really strange to me is that if I output $_REQUEST, I get everything that I would expect, all my $_GET, $_POST, and $_COOKIE, as the documentation suggests. But then I output each of $_GET, $_POST, and $_COOKIE separately, and the $_POST is empty. The other two are correct.


Let's see.

$_GET + $_POST + $_COOKIE = $_REQUEST

If we don't post anything we are left with

$_GET + $_COOKIE = $_REQUEST

Doesn't seem strange at all.





Customer since 2000 cool openvein.org

Re: $_POST empty

Posted by: leischj
Posted on: 2009-09-02 07:49:00

Perhaps I was not clear.

I shall state it another way: If I add the sizes of each array: $_GET + $_POST + $_COOKIE, the sum is 2+0+5=7.

But if I look at the size of the $_REQUEST array, it is 15, and includes all 8 items I post on the form.

So, as you can see, $_GET + $_POST + $_COOKIE != $_REQUEST, which is why I found it strange, and still do.

And yes, the value of $_SERVER['REQUEST_METHOD'] is 'POST'.

I will continue to ignore the $_POST variable since it doesn't work for me at this time.

Re: $_POST empty

Posted by: Atropos7
Posted on: 2009-09-02 11:53:00

In reply to:

I will continue to ignore the $_POST variable since it doesn't work for me at this time.


$_POST should work fine with the default install of PHP 5 by DreamHost. Perhaps you can figure out the what the problem is later when you can reduce your code to a testcase.

Customer since 2000 cool openvein.org

Re: $_POST empty

Posted by: leischj
Posted on: 2009-09-02 19:22:00

I'm aware of how $_POST *should* work, via a simple Google search. So that isn't much help. A testcase is what I started with of course. I posted my problem on another PHP board and have received several much more helpful leads that I'll look into in the morning. It looks like nothing much will come from this thread. Thanks anyway for letting me know how $_POST should work.

Tags: array