New Blog Format | Hosted on ServerDisk | Site Map
Search:
NewSourceMedia Popular Tutorials: PHP Javascripts Web Hosting
SoftwareTutorials
CATEGORIES
Scripts (2,2351) Podcast (video & audio)
 




Home / PHP / Content Management

POST/GET Form Variables

Published by: Alexander Mclean III
Using PHP array functions to view all of your POST/GET Variables make it easy for retrieving data from online forms. It's also great for debugging your codes.



Introduction:

To view all of the POST/GET Variables, you could use the following PHP statements.

NOTE: Make sure that "REGISTER_GLOBALS" are turned ON and DO NOT USE (enctype="text/plain") in your form tag or you may not be able to retrieve the posted values.

print_r($_POST);
?>

or

print_r($_GET);
?>

or you may want to see all POST/GET variables including global variables like cookies set by your web site.

print_r($_REQUEST);
?>

Here is a sample as to how the data will display after posting your form by using the above PHP statements:

Array ( [textfield1] => Alexander [textfield1] => 1 [submit] => Submit )

If you would like to change the way your POST/GET Array variables are displayed, you could do the following:

echo "POST/GET Variables:
";
foreach ($_GET as $key => $val)
echo "$key =$val
";
?>

The the code above should display something like this:

POST/GET Variables:
textfield =Mike
textfield2 =Tome
textfield3 =Sue
textfield4 =Bob
Submit =Submit

To view a working sample using the GET method, click here!

    Comments

  1. Pravin
    06.19.2008

    Hi!

    I wanted to know that How can I post a Form (containing name, email address & comments) to another webpage of my website.
    SAY:
    I've a page named "www.abc.com/123.html" which contains a form having name, email and comments fields.
    and I want the form to be posted to a page named "www.abc.com/789.html" then what ADDITIONS should I make to BOTH the pages.

    *You can show me an example of PHP also
  2. Ramy
    12.31.2005

    Thanks a lot!
  3. Chris
    07.28.2004

    How can I do this with register_globals turned OFF. can I use $HTTP_POST_VARIABLES ?
    Thank you!
    Chris
  4. antonio
    04.02.2004

    quiero probar esto para ver como rula.

    (trns: I want to prove this to see like rula)

Leave a Comment



Related Articles for PHP Content Management:
Articale POST/GET Form Variables
Using PHP array functions to view all of your POST/GET Variables make it easy for retrieving data from online forms. It's also great for debugging your codes.
Articale Array: Lesson Part 1
Learn PHP arrays and how easy it is to store and organize complex data structures.
Articale Installing PHP MySQL Apache on windows 98 in 5 min
This article on "Installing Apache-MySQL-PHP on Windows 98" in just five min is a complete step by step tutorial to install this trio package. The article contains full graphics snapshots to help the new developers to install the trio package without any
Articale PHP strip remove white space from end of string
Need to remove the white space at the end of a string before recording the data. Use PHP's rtrim().
Articale List of Top Web Hosting sites with
UNLIMITED DISK SPACE





Hosting - List of top Web Hosting Services with FTP and Unlimited Disk Space