Have a single variable URL in ColdFusion
Some websites have URLs with only a question mark and one variable, e.g. http://www.blah.com?123 or http://www.blah.com/index.cfm?123.
You can do this with ColdFusion by using
CGI.QUERY_STRING. This gives you
all of the information after the ? in the URL. As in this case there is only one piece of information
you can use it to look up a record in your database.
E.g. in the case of looking up a number as the ID:
<CFQUERY NAME="DBRead" DATASOURCE="#Datasource#">
WHERE ID = #val(CGI.QUERY_STRING)#
The 'val()' makes sure that the database looks up a number, rather than some nefarious code, see other CF security tips.
Paul Silver. February 2004