Home arrow ColdFusion arrow Page 2 - Cold Fusion Administration Module
COLDFUSION

Cold Fusion Administration Module


To create a user administration module in Cold Fusion, you would need to create templates that both provides a means to search for or select a user record, and updates the database using an update query. In this example, I created a form that uses a link with a URL parameter to select a user. Other methods would include a search block that would send information to a SELECT query.

Author Info:
By: Tim Haight
Rating: 4 stars4 stars4 stars4 stars4 stars / 7
March 03, 2004
TABLE OF CONTENTS:
  1. · Cold Fusion Administration Module
  2. · The Code for Administer.cfm
  3. · Updating the Record

print this article
SEARCH DEVARTICLES

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
.useridUsers.passwordUsers.LastNameUsers.FirstNameUsers.AddressUsers.CityUsers.StateUsers.zipcodeUsers.CountryUsers.PhoneUsers.emailUsers.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.

Cold Fusion

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">


blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials