In this example, we will create a ColdFusion template to display some commonly used CGI variables. -
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> -
Save this file into your Examples\Step02 directory as CGIVariables.cfm. -
Use a URL to browse to the page. For example, http://localhost/Examples/Step02/CGIVariables.cfm. -
You should see something similar to the page displayed in Figure 2.2. Figure 2.2. CGIVariables.cfm browser display. -
To see HTTP_REFER information, set up a hyperlink to CGIVariables.cfm on another page and use the link to jump to CGIVariables.cfm.
|