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.

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!

You may also like...

5 Responses

  1. antonio says:

    quiero probar esto para ver como rula.

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

  2. Dr. Joe says:

    I offer a Visual Basic software program that generates vouchers so that a user can be paid by for His or Her services. The program is marketed over the Internet and a potential buyer is allowed to download the software and create the first voucher at no charge.

    The user clicks a Licensing Button if he/she wishes to license the software. This takes the user to a special page of my Web Site where the purchase is made by clicking a PayPal Button.

    If the user completes the PayPal operation and submits the purchase, PayPal returns the user to a successful completion page on my Web Site. On the other hand, if the User Cancels the purchase the return is to a Canceled page on my Web Site.

    As you can see the user’s Browser knows if the User Canceled or completed the Purchase. If the User Cancels, the user must be denied access to the software.

    My question is: How do I recover this information to inform my program, which is running on the User’s machine, that the user has cancelled?

    PayPal was unable to answer the question, as were many others. I am sure there is a very simple solution to the problem but I have been working on it for over a month now without success. I will be grateful for any help you can offer.

    Dr. Joe

  3. Chris says:

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

  4. Ramy says:

    Thanks a lot!

  5. Pravin says:

    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

Leave a Reply