Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe ColdFusion

  • Print
  • + Share This
This chapter is from the book

Example 2.1: Using CGI 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.

  2. Listing 2.1 Commonly Used CGI Variables

    File:    CGIVariables.cfm
    Description: Displays some common CGI variables
       <TITLE>Common CGI Variables</TITLE>
    <!––– 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>
  3. Save this file into your Examples\Step02 directory as CGIVariables.cfm.

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

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

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

Figure 2.2Figure 2.2 CGIVariables.cfm browser display.

  • + Share This
  • 🔖 Save To Your Account