Example 2.1: Using CGI Variables

Team-Fly    

ColdFusion® MX: From Static to Dynamic in 10 Steps
By Barry Moore
Table of Contents
Step 2.  Using Variables


In this example, we will create a ColdFusion template to display some commonly used CGI variables.

  1. Open your editor and type the code shown in Listing 2.1, or you can open the CGIVariables.cfm file from the CompletedFiles\Examples\Step02 folder.

    Listing 2.1 Commonly Used CGI Variables
     <!--- File:        CGIVariables.cfm  Description: Displays some common CGI variables  Author:  Created:  --->  <HTML>  <HEAD>        <TITLE>Common CGI Variables</TITLE>  </HEAD>  <BODY>  <CFOUTPUT>  <!--- display some commonly used CGI variables --->  <B>User's Browser Type:</B> HTTP_USER_AGENT = #CGI.HTTP_USER_AGENT#<BR>  <B>User's IP Address:</B> REMOTE_ADDR = #CGI.REMOTE_ADDR#<BR>  <B>Referring Page:</B> HTTP_REFERER = #CGI.HTTP_REFERER#<BR>  <B>Server's Name:</B> SERVER_NAME=#CGI.SERVER_NAME#<BR>  <B>Server's Port:</B> SERVER_NAME=#CGI.SERVER_PORT#<BR>  </CFOUTPUT>  </BODY>  </HTML>

  2. Save this file into your Examples\Step02 directory as CGIVariables.cfm.

  3. Use a URL to browse to the page. For example, http://localhost/Examples/Step02/CGIVariables.cfm.

  4. You should see something similar to the page displayed in Figure 2.2.

    Figure 2.2. CGIVariables.cfm browser display.

    graphics/02fig02.gif

  5. To see HTTP_REFER information, set up a hyperlink to CGIVariables.cfm on another page and use the link to jump to CGIVariables.cfm.


    Team-Fly    
    Top
     



    ColdFusion MX. From Static to Dynamic in 10 Steps
    ColdFusion MX: From Static to Dynamic in 10 Steps
    ISBN: 0735712964
    EAN: 2147483647
    Year: 2002
    Pages: 140
    Authors: Barry Moore

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net