Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Kanishk Kunal

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

PHP GET and POST Variables

// The following code will easily retrieve all of the GET and POST data for you and load it into appropriately named PHP variables. The same code will also work to get parameters added to the end of URLs via other methods other than using GET with a form.

   1  
   2  $q = explode("&",$_SERVER["QUERY_STRING"]);
   3  foreach ($q as $qi)
   4  {
   5    if ($qi != "")
   6    {
   7      $qa = explode("=",$qi);
   8      list ($key, $val) = $qa;
   9      if ($val)
  10        $$key = urldecode($val);
  11    }
  12  }
  13   
  14  reset ($_POST);
  15  while (list ($key, $val) = each ($_POST))
  16  {
  17    if ($val)
  18      $$key = $val;
  19  }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS