Connecting Tech Pros Worldwide Forums | Help | Site Map

Using $_POST or $HTTP_POST_VARS etc. ?

Member
 
Join Date: Jan 2007
Posts: 47
#1: Jul 2 '08
Hi there,

I am using in principal the $HTTP_xxx_VARS since quite a while and have, because it seemed the $_POST was newer and "more efficient" slightly changed that little script which is running on my site:

[PHP]if (sizeof($_POST) > 0)
$HTTP_FORM_VARS = $_POST;
elseif (sizeof($_GET) > 0)
$HTTP_FORM_VARS = $_GET;
else
$HTTP_FORM_VARS = array("");
[/PHP]

Nevertheless, it seems when used in functions, $_POST is readable without problem whereas $HTTP_FORM_VARS isn't... Perhaps it's a problem of my script? Should I use $_POST generally?

Thanks for any advice!

Member
 
Join Date: Jan 2008
Posts: 113
#2: Jul 2 '08

re: Using $_POST or $HTTP_POST_VARS etc. ?


As far as I know $HTTP_POST_VARS etc are deprecated for php versions below 4.1.0. $_POST was introduced in this version. This link may help you some more:

http://hasin.wordpress.com/2006/06/10/difference-between-_xxx-and-http_xxx_vars/

Hope this helps.

Chromis
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,948
#3: Jul 2 '08

re: Using $_POST or $HTTP_POST_VARS etc. ?


Quote:
Should I use $_POST generally?
Yes. Yes. Yes!

$_HTTP_blah is deprecated, as someone already mentioned. Therefore, should not really be used.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Jul 2 '08

re: Using $_POST or $HTTP_POST_VARS etc. ?


Quote:

Originally Posted by luftikus143

...
Nevertheless, it seems when used in functions, $_POST is readable without problem whereas $HTTP_FORM_VARS isn't... Perhaps it's a problem of my script? Should I use $_POST generally?

Thanks for any advice!

The reason is because $_POST is a superglobal while those old things are just globals.
Why not just replace references to those old things rather than aliasing them like you are trying to do? Also ensure that you've set register globals to off after removing those things from your code.
Reply


Similar PHP bytes