How to use HTTP_POST_VARS in php

Started by VelMurugan, Apr 06, 2009, 10:07 AM

Previous topic - Next topic

VelMurugan

How to use HTTP_POST_VARS in php

HTTP_POST_VARS was a very useful global array, but we dont use it these days. I do not understand or i did not find time to research if it has been discontinued or had some problem. But it was quite a nice array which stored all the fields and their values of a html form into a key-value pair array. That certainly saves your over head of using the $_POST array repeatedly on the php page.

But as you know HTTP_POST_VARS is not used so i created a custom function which can be used to achieve the same functionality at your own. I really liked its simple approach where the power of dynamic varibles in php is utilized.


foreach($_POST as $key=>$value)
{
$$key=$value;
}

So the above line of code will create the new variables with the same name as defined on the HTML form. So if you have a input box with the name "email" you can access it on the php page as "$email" instead of $_POST["email"]

source : realin