We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

willcodeforfood on 12/16/07


Tagged

pdf


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

vali29


HTTP Submit


Published in: PHP 


URL: http://blogs.adobe.com/stevex/2006/05/http_submit.html

I've created a simple PHP script that dumps out what you submit to it parsed (so you can see what variables PHP found in the submitted data) as well as the raw POST body.

http://blogs.adobe.com/stevex/2006/05/http_submit.html

  1. <HTML>
  2. <HEAD>
  3. <TITLE>HTTP Request Dump</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <h1>HTTP Request Dump</h1>
  7. This page sends back to you what your browser or other user-agent submitted to this page.
  8.  
  9. <h2>HTTP Headers</h2>
  10. <pre>
  11. <?PHP
  12. DumpArray("HEADERS", emu_getallheaders());
  13. ?>
  14. </pre>
  15.  
  16. <h2>Submitted Variables (as parsed by PHP)</h2>
  17. <pre>
  18. <?PHP
  19. echo $content_type;
  20. DumpArray("REQUEST",$_REQUEST);
  21. ?>
  22. </pre>
  23.  
  24. <h2>Raw POST Body</h2>
  25.  
  26. <pre>
  27. <?PHP
  28. $body = file_get_contents("php://input");
  29. echo strlen($body);
  30. echo " bytes: <br>";
  31. ?>
  32. <span style="background-color: #e0e0f0">
  33. <?PHP
  34. while (strlen($body)>60) {
  35. echo substr($body, 0, 60);
  36. echo "\n";
  37. $body = substr($body, 60);
  38. }
  39. echo $body;
  40. ?>
  41. </span>
  42. </pre>
  43.  
  44. </BODY>
  45. </HTML>
  46. <?PHP
  47.  
  48. # Function DumpArray
  49. ##########################################################
  50. function DumpArray($ArrayName,&$Array) {
  51.  
  52. foreach ($Array as $Key=>$Value){
  53. echo "$Key: $Value\n";
  54. } # End of foreach ($GLOBALS as $Key=>$Value)
  55. } # End of function DumpArray
  56. #################################################
  57.  
  58.  
  59. function emu_getallheaders() {
  60. foreach($_SERVER as $h=>$v)
  61. if(ereg('HTTP_(.+)',$h,$hp))
  62. $headers[$hp[1]]=$v;
  63. $headers["CONTENT_TYPE"]=$_SERVER["CONTENT_TYPE"];
  64. return $headers;
  65. }
  66.  
  67. ?>

Report this snippet 

You need to login to post a comment.