Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[phoenix-dev] Using HTTP GET and POST parameters

Folks,

We had an issue with PHP5 (and PHP4, actually) when reading HTTP parameters. Most of our code looks something like this:

$_mirror_id    = $_GET['mirror_id'] ? $_GET['mirror_id'] : $_POST['mirror_id'];


Although this is not necessarily an error, it's bad programming in that we don't check to see if the actual value exists in the $_GET or $_POST array, which would lead to a PHP warning.

I have added a function to the App class called getHTTPParameter(). This function will properly return the value of the requested parameter, or the empty string. Please use this class when fetching GET and POST parameters. I will update the wiki page with this documentation soon, but here is how it's used:

$_mirror_id    = $App->getHTTPParameter("mirror_id");  // GET or POST if available, POST if both are defined
$_mirror_id    = $App->getHTTPParameter("mirror_id", "GET");
$_mirror_id    = $App->getHTTPParameter("mirror_id", "POST");


Denis

--
Denis Roy
Manager, IT Infrastructure
Eclipse Foundation, Inc.  --  http://www.eclipse.org/
Office: 613.224.9461 x224
Cell: 819.210.6481
denis.roy@xxxxxxxxxxx



Back to the top