Cold Fusion Administration Module - The Code for Administer.cfm
(Page 2 of 3 )
<!--Administer.cfm-->
<cfset txtTitle="Administer Users">
<CFQUERY DATASOURCE="mydb" name="qUsers">
SELECT Users.userid, Users.password, Users.LastName, Users.FirstName, Users.Address, Users.City, Users.State, Users.zipcode, Users.Country, Users.Phone, Users.email, Users.Rights
FROM Users
ORDER BY Users.userid;
</CFQUERY>
<cfinclude template="head.txt">
<cfinclude template="userinclude.cfm">
<cfinclude template="footer.txt">
<!--userrinclude.cfm-->
<div align="center"><h1>Administer Users</h1></div>
<table>
<tr>
<td width=100><B>USER ID</B></td>
<td width=200><B>LAST NAME</B></td>
<td width=200><B>FIRST NAME</B></td>
</tr>
<CFOUTPUT query="qUsers">
<tr>
<td><a href="getuser.cfm?userid=#userid#">#userid#</a></td>
<td>#lastname#</td>
<td>#firstname#</td>
</tr>
</CFOUTPUT>
</table>
In administer.cfm, there is a select query that selects the users in the USERS table. In the tag, the result is displayed in a table. A link to getuser.cfm was created, with userid as a parameter. When one of these links is clicked, a SELECT query in getuser.cfm is executed.

Below is the source code for getuser.cfm. In the tag, a select query is used to retrieve the records from the database. In the WHERE clause, the parameter passed from administer.cfm is indicted by #URL.
<!---getuser.cfm->
<cfset txtTitle="Administer Users">
<cfquery datasource="mydb" name="getuser">
SELECT * FROM USERS WHERE USERID = '#URL.USERID#'
</cfquery>
<cfinclude template="head.txt">
<div align="center"><h1>Administer Users</h1></div>
<cfform action="updateuser.cfm" name="adminform">
<CFOUTPUT QUERY="getuser">
<table>
<tr>
<td width=100><B>USER ID:</B></td>
<td><cfinput type="text" name="userid" value="#userid#"></td>
</tr>
<tr>
<td width=100><B>PASSWORD:</B></td>
<td><cfinput type="text" name="password" value="#password#"></td>
</tr>
<tr>
<td width=100><B>LAST NAME:</B></td>
<td><cfinput type="text" name="lastname" value="#lastname#"></td>
</tr>
<tr>
<td width=100><B>FIRST NAME:</B></td>
<td><cfinput type="text" name="firstname" value="#firstname#"></td>
</tr>
<tr>
<td width=100><B>ADDRESS:</B></td>
<td><cfinput type="text" name="address" value="#address#"></td>
</tr>
<tr>
<td width=100><B>CITY:</B></td>
<td><cfinput type="text" name="city" value="#city#"></td>
</tr>
<tr>
<td width=100><B>STATE:</B></td>
<td><cfinput type="text" name="state" value="#state#" maxsize="2"></td>
</tr>
<tr>
<td width=100><B>ZIP CODE:</B></td>
<td><cfinput type="text" name="zipcode" value="#zipcode#" maxsize="10"></td>
</tr>
<tr>
<td width=100><B>PHONE NUMBER:</B></td>
<td><cfinput type="text" name="phone" value="#phone#" maxsize="20"></td>
</tr>
<tr>
<td width=100><B>E-MAIL:</B></td>
<td><cfinput type="text" name="email" value="#email#"></td>
</tr>
<tr>
<td width=100><B>RIGHTS:</B></td>
<td><cfinput type="text" name="rights" value="#rights#"></td>
</tr>
</table>
</CFOUTPUT>
<input type="submit" name="submit" value="Update Record">
<input type="reset" value="Clear">
</cfform>
<cfinclude template="footer.txt">
Next: Updating the Record >>
More ColdFusion Articles
More By Tim Haight