Cold Fusion Administration Module - Updating the Record
(Page 3 of 3 )
After the record is changed, you can click the Update Record button, a select button with the value of Update Record.

In this example, the Address field has been updated. Here is the source code for updateuser.cfm.
In this template, the update to the table is made by the update query in the [CFQUERY] tag.
<!---updateuser.cfm->
<cfset txtTitle="User Updated">
<cfinclude template="head.txt">
<CFQUERY DATASOURCE="mydb" name="qUpdateUser">
UPDATE Users
SET Users.password = '#form.password#',
Users.lastname = '#form.lastname#',
Users.firstname = '#form.firstname#',
Users.address = '#form.address#',
Users.city = '#form.city#',
Users.state = '#form.state#',
Users.zipcode = '#form.zipcode#',
Users.phone = '#form.phone#',
Users.email = '#form.email#',
Users.rights = '#form.rights#'
WHERE Users.userid = #form.userid#
</CFQUERY>
<br>Record Updated<br>
<cfinclude template="userinclude.cfm">
<cfinclude template="footer.txt">
After the update is processed, a message is displayed. I also included the userinclude.cfm so that you could update another record.

Conclusion
Creating a module to update records utilizes update queries, as well as selecting records using a URL parameter. A search box could also be utilized to search for the records. These techniques could be used anytime there is a need to search for and update a record from a browser.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |