Software, your way.
burger menu icon
WillMaster

WillMaster > LibrarySnooping (Information Retrieval)

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

A Nice Data Dump

Some years ago, a form wasn't working right. The script was not receiving the form submission the way I thought it should. Or, so it appeared.

So I made a data dump, software to print a page of all the information it received. And I changed the form's action URL to the data dump page.

(A later version that provides even more information is Data Dump V2.)

It revealed I was missing a value. Checking the form source code, I found a misplaced quotation mark.

Since then, I've used the data dump a lot. Not only in debugging, but also during developing. The data dump is used whenever I have a question about what a script or web page is sending.

The code was tweaked now and again over the years to make it more efficient or to make the presentation more to my liking. What you get with this article is what I use for myself.

The data dump is a web page with PHP code.

Send anything to the data dump web page and it will report what it received — data with method GET, data with method POST, and/or cookies. The data dump will also display the environment variables it has access to.

A very, very handy tool.

The data dump may be more useful to website developers than website owners. Except for website owners who do much of their own work.

Here is the data dump source code. No edits necessary. Upload it to your server with name datadump.php or other name with .php extension. Make a note of its URL.

<html>
<head>
<title>Data Dump</title>
<style type="text/css">
a { text-decoration:none; }
body { margin:0; }
th { font-size:smaller; }
</style></head>
<body><div style="position:absolute; top:100px; left:50px;">
<a href="https://www.willmaster.com/">
<img src="https://www.willmaster.com/images/wmlogo_icon.gif" width="50" height="50" border="0" alt="Willmaster.com" title="Courtesy of Willmaster.com">
</a>
</div><div style="margin:0 0 0 150px; padding:75px 0 100px 50px; width:550px; border-left:6px groove blue;">
<h1 style="font-weight:normal; letter-spacing:3px;">Data Dump</h1>

<?php
if( count($_GET) )
{
   echo('<h4>Received data method GET &mdash;</h4>');
   PrintValues($_GET);
}
else { echo('<h4 style="font-weight:normal;">No method GET data received.</h4>'); }

if( count($_POST) )
{
   echo('<h4>Received data method POST &mdash;</h4>');
   PrintValues($_POST);
}
else { echo('<h4 style="font-weight:normal;">No method POST data received.</h4>'); }

if( count($_COOKIE) )
{
   echo('<h4>Received cookies data &mdash;</h4>');
   PrintValues($_COOKIE);
}
else { echo('<h4 style="font-weight:normal;">No cookies received.</h4>'); }

if( count($_SERVER) )
{
   echo('<h4>Environment variables &mdash;</h4>');
   PrintValues($_SERVER);
}

function PrintValues(&$ar)
{
   $tabstart = '<tr><td valign="top" style="font-family:courier,monospace;">';
   echo('<table border="1" cellpadding="5" cellspacing="0">');
   echo('<tr><th>Name</th><th>Value</th></tr>');
   ksort($ar);
   foreach($ar as $k => $v)
   {
      $pk = htmlspecialchars($k);
      if( is_array($ar[$k]) )
      {
         $counter = 0;
         $pkh = array();
         foreach( $ar[$k] as $kk => $vv )
         {
            if( empty($vv) ) { $pv = ' '; }
            else { $pv = htmlspecialchars($vv); }
            $pkh[$counter] = $pk.'['.$counter.']'."\t$pv";
            $counter++;
         }
         foreach( $pkh as $tpk => $tpv )
         {
            list($tk,$tv) = explode("\t",$tpv,2);
            echo("${tabstart}$tk</td><td>$tv</td></tr>");
         }
      }
      else
      {
         if( empty($v) ) { $pv = ' '; }
         else { $pv = htmlspecialchars($v); }
         echo("${tabstart}$pk</td><td>$pv</td></tr>");
      }
   }
   echo('</table>');
}
?>
<p style="margin-top:50px;">
Copyright 2011 <a href="https://www.willmaster.com/">Bontrager Connection, LLC</a>
</p>
</body>
</html>

A form not working? Change the action= URL to the URL of the data dump web page. The data dump will tell you what it received. If it's not reported by the data dump, it was not received.

A script not working? If the bug has to do with sending information to another script or web page, whether method GET or POST, use the data dump to reveal exactly what is sent.

The data dump is a PHP web page, a handy tool, nice to work with. Install it on your server, ready to assist.

The data dump reveals the data it received, whether it is called via a form action, a clicked link, or by typing its URL directly into the browser.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC