This is a discussion on ColdFusion Tips & Tricks within the ColdFusion Programming forums, part of the Web Development category; Passing information from a child window to the parent window The child window can refrence the information in the parent ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Passing information from a child window to the parent window The child window can refrence the information in the parent window using the "opener" name in the child window. Attached is the code I have in passing date information between two forms. Note in this case that I'm required to use three fields, one each for Month, Day, and Year. Example HTML/CFML code: Code: <!--- Child window Javascript --->
function chooseDate()
{
var day = window.status
var dateOne = this.month + 1;
if (Number(day) < 10)
{
day = Number(day);
day = '0' + day;
}
if (Number(dateOne) < 10)
{
dateOne = Number(dateOne);
dateOne = '0' + dateOne;
}
this.day = day
this.dateOne = dateOne
this.dateFieldm = opener.dateFieldm;
this.dateFieldd = opener.dateFieldd;
this.dateFieldy = opener.dateFieldy;
dateFieldm.value = dateOne;
dateFieldd.value = this.day;
dateFieldy.value = this.year;
window.close()
} |
| Sponsored Links |
| |||
| Passing variables between clustered servers The problem with running an application in an clustered environment is that when you update an Application scope variable on one box, the change does not propagate to the other boxes. The SendApplicationVar( ) UDF below handles it for you. First, we need to set up a few Request variables. Ideally, these would exist in your environment.cfm template. First, we need to configure the URL's for the different clustered servers - use the actual name of the server (or the IP address), not the shared name. For single server environments (such as dev/test/uat), set it to your server's name/IP and port. If the port is 80, you may leave it out. If you run multiple applications under the same port (such as 8500), enter the path of the application after the ip/port number. Code: <!--- Single server configuration ---> <CFSET Request.ClusterList="127.0.0.1:9091"> <!--- Single server, shared port configuration ---> <CFSET Request.ClusterList="127.0.0.1:8500/myappdir"> <!--- Multiple server configuration ---> <CFSET Request.ClusterList="iwof1.fubar.com,iwof2.fubar.com,iwof3.fubar.com"> Code: <CFSET Request.AdminRoot="iwantmy"> <CFSET Request.AdminPasswd="moogie"> Once you CFINCLUDE the UDF (or have it coded in-line), the below code will propagate a variable and a structure to all of the servers. Code: <cfscript> Out=StructNew(); Out.TestVar=StructNew(); Out.TestVar.Foo="Strong"; Out.Bar="FUBAR"; SendApplicationVar(Out); </cfscript> SendApplicationVar( ) will return a 1 if all servers were updated successfully, 0 otherwise. Example HTML/CFML code: Code: <cffunction name="SendApplicationVar" access="private" returntype="string">
<cfargument name="InStruct" type="struct" required="yes">
<cfscript>
var Results="";
var OutStruct=StructNew();
var ErrorCode=1;
// Add authentication
OutStruct.Auth=StructNew();
OutStruct.Auth.UserID=Request.AdminRoot;
OutStruct.Auth.Password=Request.AdminPasswd;
OutStruct.Application=Duplicate(Arguments.InStruct);
</cfscript>
<CFPARAM name="Request.ClusterList" default="">
<CFIF Len(Trim(Request.ClusterList)) GT 0>
<cfwddx action="CFML2WDDX" input="#OutStruct#" output="OutWDDX" usetimezoneinfo="Yes">
<CFLOOP index="CurrBox" list="#Request.ClusterList#">
<!--- Send the WDDX packet to the remote servers, change path to suit -->
<cfhttp url="http://#CurrBox#/common/isolated/receive_var.cfm" method="POST">
<cfhttpparam type="FORMFIELD" name="InVar" value="#OutWDDX#">
</cfhttp>
<CFIF Left(CFHTTP.FileContent,2) NEQ "Ok">
<CFOUTPUT>#CurrBox#: #CFHTTP.FileContent#<br></CFOUTPUT>
<CFSET ErrorCode=0>
</CFIF>
</CFLOOP>
<CFRETURN ErrorCode>
</CFIF>
</cffunction> receive_var.cfm *************** Code: <CFPARAM name="FORM.InVar" default="">
<CFIF Left(FORM.InVar,20) NEQ "<wddxPacket version=">
<CFOUTPUT>Invalid WDDX Packet</CFOUTPUT>
<CFABORT>
</CFIF>
<cfwddx action="WDDX2CFML" input="#FORM.InVar#" output="InStruct">
<CFIF IsStruct(InStruct) EQ "NO">
<CFOUTPUT>Invalid Structure</CFOUTPUT>
<CFABORT>
</CFIF>
<CFIF IsDefined("InStruct.Auth.UserID") EQ "NO" OR IsDefined("InStruct.Auth.Password") EQ "NO">
<CFOUTPUT>Invalid Authentication</CFOUTPUT>
<CFABORT>
</CFIF>
<CFIF InStruct.Auth.UserID NEQ Request.AdminRoot OR InStruct.Auth.Password NEQ Request.adminpasswd>
<CFOUTPUT>Invalid Authentication</CFOUTPUT>
<CFABORT>
</CFIF>
<CFIF IsDefined("InStruct.Application")>
<CFSET KeyList=StructKeyList(InStruct.Application)>
<cflock timeout="30" throwontimeout="Yes" type="EXCLUSIVE" scope="APPLICATION">
<CFLOOP index="CurrKey" list="#KeyList#">
<CFSET "Application.#CurrKey#"=Duplicate(Evaluate("InStruct.Application.#CurrKey#"))>
</CFLOOP>
</cflock>
</CFIF>
<CFOUTPUT>Ok</CFOUTPUT> |
| |||
| Populating Text fields based off a drop-down selection box If you want to auto-populate certain text fields based off a section in a drop-down selection box, you can use the code below as an example. This example will populate a text box with the month selected in the drop-down selection box. Example HTML/CFML code: Code: <html>
<head>
<script language="Javascript">
function Populate(idx)
{
MonthList = new Array('January','Feburary','March','April','May','June','July','August','September','October','November','December');
document.MyForm.Month2.value=MonthList[idx];
}
</script>
</head>
<body>
<form name="MyForm">
Select a month:
<select name="Month1" size="1" onChange="Populate(this.selectedIndex)">
<CFLOOP index="loop" from="1" to="12">
<CFOUTPUT><option>#loop#</option></CFOUTPUT>
</CFLOOP>
</select>
<br>
You selected the month of
<input type="Text" name="Month2">
</form>
</body>
</html> |
| |||
| Preventing a user from Reloading a page and causing duplicate updates If you ever have a problem where a user submits information to your website and it goes BOOM if they hit the Reload/Refresh button, here is a simple way to prevent it from happening. Instead of the program that processes the updates also displaying the results of the updates, have the update program use the CFLOCATION tag to redirect to a 3rd program that displays the results. 1. User enters information into a form and hits the Submit button. 2. Submit program executes a program that performs the updates. 3. The Update program uses CFLOCATION to jump to a program that displays the results. 4. The Results program displays the results. This way, if the user hits the Reload/Refresh button, the only thing that happens is the Results program re-running and not the Update program. Note that if the Update program redirects to the same program that called it via the form Action tag, you will need to force the browser to not cache the document by adding the following line to your <head></head> block: <META HTTP-EQUIV="expires" CONTENT="Fri, 1 Jan 1990 00:00:00 GMT"> |
| |||
| Query Caching If you do not have a version of Cold Fusion that supports query caching, you can use an application variable for the query name and the query will always be available in memory. I have an example in the accompanied HTML/CFML code block below that you can use to model your query after. Put this in your application.cfm so that the query will always be available to any programs that need it. To reference the application query, simply use the application variable name. Just remember, queries such as these should be relativly small as they will be consuming system resources. Example HTML/CFML code: Code: <CFIF IsDefiend("application.MyQuery") EQUAL "No">
<CFQUERY name="application.MyQuery" .....>
SELECT *
FROM MyTable
</CFQUERY>
</CFIF>
....
<CFLOOP query="application.MyQuery")>
...
</CFLOOP> |
| |||
| Reading a text file, one line at a time The problem with parsing text files is that the common method is to load the entire file into memory and then loop over it as a list element. With CFML, that is the only way to do it. However, if the file is large, it can cause problems. CF5 and below, for example, will blow chunks and commit suicide if you try to load a 5 meg file into memory. With MX, you can load a large file into memory and it'll chew through it like a hot knife through butter but it can take quite some time to load a file into memory and then you have a much larger memory footprint to concern yourself with. And what if you needed to parse a 200 meg text file? S.O.L.? With CF5, you were. However, with MX's ability to create java objects, you can interface with the Java subsystem and access the text files with it. Using this method, you can read in a file one line at a time with little to no delays. If you want to parse in a text file one line at a time instead of reading the entire file into memory, this little block of code will handle that for you. Put in your text file, path and file name, in the FileName filed and run the template. It seems to work fine with both Unix and Windows line breaks. Example HTML/CFML code: Code: <cfscript>
// Define the file to read, use forward slashes only
FileName="C:/Example/ReadMe.txt";
// Initilize Java File IO
FileIOClass=createObject("java","java.io.FileReader");
FileIO=FileIOClass.init(FileName);
LineIOClass=createObject("java","java.io.BufferedReader" );
LineIO=LineIOClass.init(FileIO);
</cfscript>
<CFSET EOF=0>
<CFLOOP condition="NOT EOF">
<!--- Read in next line --->
<CFSET CurrLine=LineIO.readLine()>
<!--- If CurrLine is not defined, we have reached the end of file --->
<CFIF IsDefined("CurrLine") EQ "NO">
<CFSET EOF=1>
<CFBREAK>
</CFIF>
<CFOUTPUT>#CurrLine#<br></CFOUTPUT><CFFLUSH>
</CFLOOP> |
| |||
| Reading BINARY files in MX Under Cold Fusion MX, you can treat Binary Files as Read-Only data. IE: You can read the file but you can't write to it. However, it's not clear that you can do so. It was only doing some detective work after looking at the source code for MX's version of the CFDUMP tag did I figure it out. When you read in a file using the BINARYFILE type in the <CFFILE> tag, you can access the binary data variable as a one dimensional array (each byte gets it's own row). The binary data is stored in ASCII format - it stores the numerical value of the character. However, if the character has an ASCII value of 128 or higher, the internal representation has 256 subtracted from it. So, the value stored in the "binary" array ranges from -128 to 127. Here's a UDF that will return the ASCII value of the position you specify. Note that this UDF the binary file as 1 base instead of 0 base. This means that the 1st byte in the file is referenced as 1 instead of 0. Code: <cfscript>
function Get(BVar,loc)
{
if (isBinary(BVar) EQ "No") return 0;
if (BVar[loc] GTE 0) return BVar[loc];
return BVar[loc] + 256;
}
</cfscript> Example to display the ASCII value of the first 100 characters in a file. Code: <cffile action="READBINARY" file="C:\Test1.pdf" variable="Data"> <CFLOOP index="loop" from="1" to="100"><CFOUTPUT>#Chr(Get(Data,loop))#</CFOUTPUT></CFLOOP> |
| |||
| Reprocessing bounced emails The problem I have always seen with ColdFusion's internal mailer is, well, it is kinda stupid. If it can not send an email the first time successfully, it dumps it in the undeliverable directory and ignores it forever. Even if there was nothing wrong with the email itself, it'll reject it if it can not connect to the mail server as well due to network problems or whatnot. So I wrote a little simi-intelligent tool to allow you to reprocess an undeliverable email up to five times before it's permanently deleted off of the server (or you can modify the code to move it elsewhere for later review). Installing is easy, stuff the file somewhere on your server (like in the CFIDE directory) and update line #6 to reflect the mail directory on your server (such as "C:\CFusion\Mail"). Then set up a scheduled task to run it every five minutes from 00:00:00 to 23:59:59. Do be sure to purge your Undelivr directory before running it the first time - there may be quite a bit of old emails in there. Example HTML/CFML code: Code: <cfapplication name="MailCheck" sessionmanagement="Yes"
sessiontimeout="#CreateTimeSpan(0,0,0,1)#"
applicationtimeout="#CreateTimeSpan(0,1,0,0)#">
<!--- ColdFusion's Mail directory --->
<CFSET MailRoot="E:\CFusion\Mail">
<!--- Copy the key list form the Application scope --->
<cflock timeout="30" throwontimeout="Yes" type="EXCLUSIVE" scope="APPLICATION">
<CFPARAM name="Application.EmailKeys" default="">
<CFIF IsArray(Application.EmailKeys) EQ "No">
<CFSET Application.EmailKeys=ArrayNew(2)>
</CFIF>
<CFSET Keys=Duplicate(Application.EmailKeys)>
</cflock>
<!--- Set a "Successfully Sent Flag" so that we know if the email managed to make it through the mail server --->
<CFLOOP index="KeyLoop" from="1" to="#ArrayLen(Keys)#">
<CFSET Keys[KeyLoop][3]=0>
</CFLOOP>
<!--- Get a list of bounced mail --->
<cfdirectory action="LIST" directory="#MailRoot#/UnDelivr" name="Dir">
<CFLOOP query="Dir">
<CFSET cr=CurrentRow>
<CFIF Dir.Type EQ "File">
<!--- Read in the file and generate a unique Hash value from the contents to identify this email from all the others --->
<cffile action="READBINARY" file="#MailRoot#/UnDelivr/#Dir.Name[cr]#" variable="FileData">
<CFSET FileHash=Hash(ToBase64(FileData))>
<!--- If Ok stays zero, it's a new email that we haven't seen before --->
<CFSET Ok=0>
<!--- Loop over the bounced emails we've already logged --->
<CFLOOP index="KeyLoop" from="#ArrayLen(Keys)#" to="1" step="-1">
<CFIF Keys[KeyLoop][1] EQ FileHash>
<CFSET Keys[KeyLoop][2]=Keys[KeyLoop][2] + 1>
<CFIF Keys[KeyLoop][2] GT 5>
<!--- We've tried to send this email five times already, kill it (or if you wish, move to a different directory) --->
<cffile action="DELETE" file="#MailRoot#/UnDelivr/#Dir.Name[cr]#">
<CFSET Jnk=ArrayDeleteAt(Keys,KeyLoop)>
<CFSET Ok=1>
<CFELSE>
<!--- We've tried to send this email five times or less so far, let's try again --->
<cffile action="MOVE" source="#MailRoot#/UnDelivr/#Dir.Name[cr]#" destination="#MailRoot#/Spool/#Dir.Name[cr]#">
<CFSET Ok=1>
<CFSET Keys[KeyLoop][3]=1>
</CFIF>
</CFIF>
</CFLOOP>
<CFIF Ok EQ 0>
<!--- It's a new email, let's add it to our list --->
<CFSET NR=ArrayLen(Keys) + 1>
<CFSET Keys[NR][1]=FileHash>
<CFSET Keys[NR][2]=1>
<CFSET Keys[NR][3]=1>
<cffile action="MOVE" source="#MailRoot#/UnDelivr/#Dir.Name[cr]#" destination="#MailRoot#/Spool/#Dir.Name[cr]#">
</CFIF>
</CFIF>
</CFLOOP>
<!--- Purge emails from the array that were successfully sent --->
<CFLOOP index="KeyLoop" from="#ArrayLen(Keys)#" to="1" step="-1">
<CFIF Keys[KeyLoop][3] EQ 0>
<CFSET Jnk=ArrayDeleteAt(Keys,KeyLoop)>
</CFIF>
</CFLOOP>
<cflock timeout="30" throwontimeout="Yes" type="EXCLUSIVE" scope="APPLICATION">
<CFSET Application.EmailKeys=Duplicate(Keys)>
</cflock> |
| |||
| Restricting the amount of data a user can enter in a textarea form field If you want to limit how many characters a user enters in a Text Area form field, you can use the onKeyDown function to check the length of the string with the key the user just pressed. If it exceeds a certain value, you can actually cancel that keypress. Example HTML/CFML code: Code: <html>
<head>
<script language="Javascript1.2">
function checkLength()
{
if (document.MyForm.Desc.value.length > 9)
{
alert('You may only enter 10 characters in the description field.');
return false;
}
}
</script>
</head>
<body onLoad="document.MyForm.Desc.focus()">
<form name="MyForm">
Please tell us a <i>little</i> bit about yourself (10 characters max)<br>
<textarea name="Desc" rows="4" cols="40" wrap="off" onKeyDown="return checkLength(event,'1')"></textarea>
</form>
</body> |
| |||
| Scheduling a program to execute only on certain days Create your program and add it to the Cold Fusion Scheduler via the Administration pages to execute every day at the time you desire. Then add the following code at the beginning of the program. This code will only allow the program to execute on the 15th and the last day of each month. If you need it to execute on any other days, simply modify the CFIF conditions to include it. Example HTML/CFML code: Code: <CFIF Day(Now()) NOT EQUAL 15 AND Day(Now()) NOT EQUAL DaysInMonth(Now())> <CFABORT> </CFIF> |
| |||
| Select All/Deselect All button Sometimes it's nice NOT to bulk up a site with too many buttons, so here is a button that has two functions: to select all, and then to deselect all. Why would you do something like this? Well, many of the pages I develop are web implementations existing paper forms. In many cases the person is requested to check of a variety of options, and most times they simply select all. If you watch someone fill out a form manually (pen and paper) they can 'zip-zip-zip' knock off a dozen radio buttons in a second or two. BUT watch someone do the same on a web form and it takes much more time. They get frustrated, but this can easily be remedied by a simple 'select all' function. Also, in cases where the user requires 9 of 10 options, it's quicker to select all, then deselect the one option they don't want. However, if they choose all by mistake, they need a way to back out without resetting the entire form, or manually deselecting all. This javascript fulfills the requirement of giving full functionality to the user without having to provide multiple buttons. The button itself can easily be replaced by a gif, radiobutton or checkbox. I recognize that this is primarily for ColdFusion, but it's hard to develop a good CF site without using client-side javascript. Example HTML/CFML code: Code: <html>
<head>
<title>one button - two actions</title>
</head>
<body>
<form>
A<input type="checkbox" name="A">
B<input type="checkbox" name="B">
C<input type="checkbox" name="C">
D<input type="checkbox" name="D">
E<input type="checkbox" name="E">
F<input type="checkbox" name="F">
G<input type="checkbox" name="G">
H<input type="checkbox" name="H">
I<input type="checkbox" name="I">
<font color="White">--------</font>
<input type="button" name="allNone" value="check / uncheck all" onclick="selectAll()">
</form>
<script language="JavaScript1.2">
selectVal = true;
function selectAll()
{
if(selectVal == true)
{
value = true;
selectVal = false;
} else {
value = false;
selectVal = true;
}
document.forms[0].A.checked = value;
document.forms[0].B.checked = value;
document.forms[0].C.checked = value;
document.forms[0].D.checked = value;
document.forms[0].E.checked = value;
document.forms[0].F.checked = value;
document.forms[0].G.checked = value;
document.forms[0].H.checked = value;
document.forms[0].I.checked = value;
}
</script>
</body>
</html> |
| |||
| Sorting an Array by the 2nd dimension If you wish to sort by the 2nd demension, specify the first deminsion in with the array in the ArraySort. Here is the example from the CF 4.5 ArraySort example, modifed to sort via the 2nd deminsion: Code: <CFSET myAlphaArray = ArraySort(myArray[2], "textnocase", "desc")> In the attached code below, I create an array with 3 rows and 26 cells in each row. I sort only the 2nd row by alpha descending. Rows 1 and 3 remain in the orignial sort order. When the program executes, you'll see two tables like the following: q w e r t y u i o p l k j h g f d s a z x c v b n m q w e r t y u i o p l k j h g f d s a z x c v b n m q w e r t y u i o p l k j h g f d s a z x c v b n m q w e r t y u i o p l k j h g f d s a z x c v b n m z y x w v u t s r q p o n m l k j i h g f e d c b a q w e r t y u i o p l k j h g f d s a z x c v b n m Example HTML/CFML code: Code: <CFSET list="q,w,e,r,t,y,u,i,o,p,l,k,j,h,g,f,d,s,a,z,x,c,v,b,n,m">
<CFSET myarray=ArrayNew(2)>
<CFLOOP index="x" from="1" to="3">
<CFLOOP index="y" from="1" to="26">
<CFSET myarray[x][y]=ListGetAt(list,y)>
</CFLOOP>
</CFLOOP>
<table border="1">
<CFLOOP index="x" from="1" to="3">
<tr>
<cfloop index="y" from="1" to="26">
<CFOUTPUT><td>#myarray[x][y]#</td></CFOUTPUT>
</CFLOOP>
</tr>
</CFLOOP>
</table>
<br><br>
<CFSET tmp=ArraySort(myarray[2],"textnocase", "desc")>
<table border="1">
<CFLOOP index="x" from="1" to="#ArrayLen(myarray)#">
<tr>
<cfloop index="y" from="1" to="26">
<CFOUTPUT><td>#myarray[x][y]#</td></CFOUTPUT>
</CFLOOP>
</tr>
</CFLOOP>
</table> |
| |||
| Speeding up a query If you have a slow query that executes slowly, there are a few things you can do to try to speed it up. * Create indexes on the fields specified in the WHERE clause. * If the PK or index consists of multiple fields, refrence the fields in the same order in the WHERE clause. * If a condition will eliminate a large amount of rows being returned, place it first in the where clause. From Ian Rutherford: Oracle reads the WHERE conditions from bottom to top so put your largest eliminator at the bottom. * Group the conditions together by table in the where clause. * If you are expecting to return a lot of data, add the blockfactor parameter to the CFQUERY statement (ie: blockfactor="1000"). By default, the datasource will return each record returned by the query one record at a time. If you are expecting a large amount of data, the blockfactor will instruct the datasource to return x number of records at once and not one by one. |
| |||
| The CFAPPLICATION tag and Session variables In order to use session variables, first you have to instruct the Cold Fusion server that you wish to use them. Code: <cfapplication name="PickSomeUniqueName"
ClientManagement="No"
SessionManagement="Yes"
SessionTimeout="0,0,30,0"
SetClientCookies="Yes"> Once you set the CFAPPLICATION tag, simply prefix any variables that you want to be access across multiple pages with "session.". For example, once you set the variable "session.userid", all of your pages can use it. Keep in mind that you'll have to code in some sort of check to see if the session variables have expired. You can either define them with a default value or if the session variable doesn't exist, redirect them to your login page. <!--- Check to see if the session variable exists, if not set it. ---> <CFPARAM name="session.IsLoggedIn" default="N"> <!--- Check to see if the session variable exists, if not redirect them to the login page ---> Code: <CFIF IsDefined("session.IsLoggedIn") EQUAL "No">
<CFLOCATION URL="/login.cfm">
</CFIF> |
| |||
| Using the Javascript "onChange" function in a CFSELECT field If you are using a version of Cold Fusion that will not allow you to pass additional parameters to the form field, you can use this method to trick Cold Fusion into the onChange be displayed. Note that this only work if you are not using any Cold Fusion form field validation. See the attached code. Note that I did not put any closing quotes at the end of the onChange call - Cold Fusion will do that thinking it's still part of the name attribute. Example HTML/CFML code: Code: <CFSET tmp="usercode#Chr(34)# onChange=#Chr(34)#pushForm()">
<cfselect name="#tmp#"
query="staff"
value="staffid"
display="name"
selected="0"
class="textblue">
</cfselect> |
| |||
| Using User ID's and Passwords If you want to restrict access to your entire website or to certain pages, you can use the code displayed below to enable it. The first part, Application.cfm, shows you the things you need to have in your Application.cfm template. You need to define an CFAPPLICATION tag, define a session variable named "user" if it doesn't exist, and include a 2nd template called Security.cfm. This Security.cfm template checks to see if the user is currently logged in and if not, displays a login screen. If you wish to only restrict certain pages, move the cfinclude tag for the Security.cfm template from the Application.cfm to the first line of the templates you wish to restrict. The nice thing about this code is that if a user times out somewhere in the middle of the website, they are not forced back to the front page - they are returned to whatever page they were trying to load. However, this login procedure will fail if you don't have a template defined in the url (ie: http://mysite.com/mydir/ instead of http://mysite.com/mydir/index.cfm). Another drawback is in passing form variables. This example doesn't preserve any form variables passed during the login process but there are tags in the Tag Gallery that can do this for you. Example HTML/CFML code: Code: <!--- Application.cfm --->
<CFAPPLICATION NAME="MySessionName"
SESSIONMANAGEMENT="Yes"
SESSIONTIMEOUT="#CreateTimeSpan(0,1,0,0)#">
<CFPARAM NAME="session.user" DEFAULT="unknown">
<CFINCLUDE TEMPLATE="Security.cfm">
<!--- Security.cfm --->
<CFPARAM name="LoginSubmit" default="">
<CFPARAM name="i_userid" default="">
<CFPARAM name="i_password" default="">
<CFIF LoginSubmit EQUAL "Login">
<CFQUERY name="login" datasource="#db#">
SELECT UserID, Password
FROM Users
WHERE UserID='#i_userid#'
</CFQUERY>
<CFIF login.UserID EQUAL i_userid
AND login.Password EQUAL i_password>
<CFSET session.user=i_userid> |