PHP form action page - for debugging

Does anyone have a generic PHP page to put into form as the action page to be used for debugging purposes.

What I want to have happen is create a form that has many selections, items, options, etc. To debug before going to production, I want a simple html/php “action” page that it goes to that simply has two columns, one with all of the variable names and the next column the respective variable associated that was passed through the form onto the page.

So for example, the landing action page would say something like this:


VARIABLES |  VARIABLE_VALUE
$NAME  |   JOHN
$AGE   |    30
$SEX    |   MALE
$HEIGHT    |   unassigned

my php skills are lame but i assume that this will use some type of loop to grab all of the variables, put them into some type of array and then display it out for easy viewing?

Here ya go:

<b>GET:</b><br />
<pre><?php print_r($_GET); ?></pre>

<b>POST:</b><br />
<pre><?php print_r($_POST); ?></pre>

Try


<?php
foreach($_POST as $key => $value){
echo"$key | $value<br>";
}
?>

I would even go so far as to not use html, because certain subtleties can be hidden by it.


<?php
header('content-type: text/plain;charset=utf-8');
//header('content-type: text/plain;charset=iso-8859-1'); //adjust charset as neccesary
print_r($_GET);
print_r($_POST);

var_dump($_GET);
var_dump($_POST);

Yes! This is exactly what i was looking for.

I had no idea about the print_r displaying the array data as well as var_dump :shifty:

While the output from var_dump is a bit more noisy, be aware of the benefits. It doesn’t just show the values, it also shows you the php data type of the value as well. And, for strings, it also tells you the length of the string(and quotes the string). Looking at the string, with quotes marking the beginning/end, as well as taking note of the length of the string can reveal spaces and other characters that aren’t otherwise easily noticed, or in some cases even visible at all. It’s a real gem of a function.