Posted By

sorehead on 10/09/06


Tagged


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

vali29
hudge
willcodeforfood
ninedaysoff
grkkid


PHP GET and POST variables


 / Published in: PHP
 

  1. <?php
  2. /*
  3. PHP GET and POST Variables
  4.  
  5. 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. */
  6.  
  7. $q = explode("&",$_SERVER["QUERY_STRING"]);
  8. foreach ($q as $qi)
  9. {
  10. if ($qi != "")
  11. {
  12. $qa = explode("=",$qi);
  13. list ($key, $val) = $qa;
  14. if ($val)
  15. $$key = urldecode($val);
  16. }
  17. }
  18.  
  19. reset ($_POST);
  20. while (list ($key, $val) = each ($_POST))
  21. {
  22. if ($val)
  23. $$key = $val;
  24. }
  25. ?>

Report this snippet  

You need to login to post a comment.