WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Display variables when a form is submitted using POST/GET
Categories : PHP, Functions, Variables, Debugging Click here to Update Your Picture
Narendra Jain
Date : May 03rd 2004
Grade : 4 of 5 (graded 3 times)
Viewed : 31570
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Narendra Jain
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

One of the major problems faced with dealing with forms, forms submitted, variables used in the form and to find out what exactly should the processing script expect in terms of variable names and variable values is to be able to process each variable which is passed through to the script.

The forms can be submitted using either the POST or GET methods. The function given below gets ALL (and we actually mean ALL!) variables passed through to the processing script, displays them in a table format - 2 columns for variable name and variable value.

This helps in making sure that proper / correct variables are used and processed. This is an excellent tool in debugging your forms.

function display_post_get() {
   if ($_POST) {
      echo "Displaying POST Variables: <br> \n";
      echo "<table border=1> \n";
      echo " <tr> \n";
      echo "  <td><b>result_name </b></td> \n ";
      echo "  <td><b>result_val  </b></td> \n ";
      echo " </tr> \n";
      while (list($result_nme, $result_val) = each($_POST)) {
         echo " <tr> \n";
         echo "  <td> $result_nme </td> \n";
         echo "  <td> $result_val </td> \n";
         echo " </tr> \n";
      }
      echo "</table> \n";
   }
   if ($_GET) {
      echo "Displaying GET Variables: <br> \n";
      echo "<table border=1> \n";
      echo " <tr> \n";
      echo "  <td><b>result_name </b></td> \n ";
      echo "  <td><b>result_val  </b></td> \n ";
      echo " </tr> \n";
      while (list($result_nme, $result_val) = each($_GET)) {
         echo " <tr> \n";
         echo "  <td> $result_nme </td> \n";
         echo "  <td> $result_val </td> \n";
         echo " </tr> \n";
      }
      echo "</table> \n";
   }
}
// End of display_post_get




Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts.
Categories : HTML, Variables, Debugging, PHP, HTTP
How to implement a session tracking system.
Categories : PHP, Sessions, Variables
Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI
Categories : Variables, PHP Options and Info, Arrays, URLs, PHP
Visits-tracking
Categories : PHP, Databases, MySQL, Errors and Logging, Functions
Memory Growth, Memory Leaks, Garbage Collection.
Categories : Debugging, PHP
Global Dump Highlighted
Categories : PHP, Variables, Global Variables
An email validation script that actually checks against the recipient's mail server.
Categories : Email, Complete Programs, PHP, Network, Debugging
Custom error messages.
Categories : PHP, Debugging
clearing variables in php3
Categories : Variables, Arrays, PHP
Example of function to send out email if error occurs
Categories : PHP, Email, Debugging, Errors and Logging
The following snippet gives complete info about all submitted HTTP_POST_VARS and HTTP_GET_VARS
Categories : Variables, HTTP, PHP
Upload any fixed type of files, control file type through javascript and encrypt filename using php so file not get overwrite
Categories : PHP, Java Script, Functions, PHP References, Form Processing
getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
Newbie Notes #5 - To double quote, or single quote, that is the question
Categories : PHP, Beginner Guides, Variables
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
 sean meese wrote : 1100
That`s a very nice way to display arrays :)

A much smaller solution that I use:

echo "&lt;pre&gt;",print_r($_POST),"&lt;/pre&gt;";
echo "&lt;pre&gt;",print_r($_GET),"&lt;/pre&gt;";

This also works for ANY type of array:

echo "&lt;pre&gt;",print_r($_SESSION),"&lt;/pre&gt;";
echo "&lt;pre&gt;",print_r($_COOKIE),"&lt;/pre&gt;";
echo "&lt;pre&gt;",print_r($users),"&lt;/pre&gt;";

etc.

It`s not nearly as pretty as the solution posted above, but it works well enough.
 
 Amado Ohland wrote : 1329
Great code, easy to understand and re-tool for my purposes. I tried it and it worked, simple as that. Well documented. Thanks.
 
 Moe Coder wrote :1359
first, "to each their own..."
second, here`s mine:

# ---- DEBUGGER TOOL: DUMP INCOMING ---- #
function dumpIncoming() {
   foreach ($_GET as $var =&gt; $value) {
      print "G: $var = $value&lt;br&gt;\n";
   }
   foreach ($_POST as $var =&gt; $value) {
      print "P: $var = $value&lt;br&gt;\n";
   }
   foreach ($_SESSION as $var =&gt; $value) {
      print "S: $var = $value&lt;br&gt;\n";
   }
   foreach ($_COOKIE as $var =&gt; $value) {
      print "C: $var = $value&lt;br&gt;\n";
   }
}
# -------------------------------------- #