Get vs. Post

There are two methods to send form results to another page:

  1. GET method - appends the name/value pairs to the URL and submits the results in the QueryString.
    For Example: http://www.halharris.com/282ExReceiveFormVariableUsingGet.asp?var=My+Name
    For Example: http://www.halharris.com/282ExReceiveFormVariableUsingGet.php?var=My+Name

    In ASP, the receiving page will use  VariableName = request.querystring("NameOfVariable") to obtain the value of the variable passed from the form on the previous page. To display the value we could use response.write "Value was-->" & VariableName.

    In PHP, the receiving page will use  $VariableName = $_GET["NameOfVariable"]; to obtain the value of the variable passed from the form on the previous page. To display the value we could use echo "Value was-->" . $VariableName;.

    Although this makes it easy for programmers to see what was sent, you would not want to use the GET method to send sensitive information such as a credit card number or a password. Also, the amount of data is limited in size to the maximum length of the request string.

    Check out the GET example using ASP: 282ExPassVarFormUsingGET.htm.
    Check out the GET example using PHP: 282ExPassVarFormUsingGETphp.htm.
     
  2. POST method - sends the name/value pairs embedded in the header and does not appear in the address as part of the URL. Although the fields are hidden from the user, the user can view source. Also, you can send larger amounts of information with the POST method.

    The receiving page will use  VariableName = request.form("NameOfVariable") to obtain the value of the variable passed from the form on the previous page. To display the value we could use response.write("Value was-->" & VariableName).

    Check out the POST example using ASP: 282ExPassVarFormUsingPOST.htm.
    Check out the POST example using PHP: 282ExPassVarFormUsingPOSTphp.htm.

You do not have to have it send the variable information to another page by using action="SecondPage.asp" in the form tag. We can set the action property to the name of the current page and have it post the results to itself. Here is an example: 282ExGetAndPostInSamePage.asp.