Return to Snippet

Revision: 1447
at October 9, 2006 11:11 by sorehead


Updated Code
<?php
/*
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. */

$q = explode("&",$_SERVER["QUERY_STRING"]);
foreach ($q as $qi)
{
  if ($qi != "")
  {
    $qa = explode("=",$qi);
    list ($key, $val) = $qa;
    if ($val)
      $$key = urldecode($val);
  }
}
 
reset ($_POST);
while (list ($key, $val) = each ($_POST))
{
  if ($val)
    $$key = $val;
}
?>

Revision: 1446
at October 9, 2006 11:05 by sorehead


Initial Code
<?php
/*
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. */

$q = explode("&",$_SERVER["QUERY_STRING"]);
foreach ($q as $qi)
{
  if ($qi != "")
  {
    $qa = explode("=",$qi);
    list ($key, $val) = $qa;
    if ($val)
      $$key = urldecode($val);
  }
}
 
reset ($_POST);
while (list ($key, $val) = each ($_POST))
{
  if ($val)
    $$key = $val;
}
?>

Initial URL

                                

Initial Description

                                

Initial Title
PHP GET and POST variables

Initial Tags

                                

Initial Language
PHP