If you want to manually iterate over all form fields, the easiest way is cfloop:
<cfloop collection="#form#" item="variables.name"> #variables.name#=(#form[variables.name]#)<br/> </cfloop>
But this says that for error email purposes, it will probably be easier for you to simply โresetโ the form area (which is just a special structure), for example:
<cfmail from=" errors@ #cgi.server_name#" to=" you@yourdomain.com " subject="Error Occurred in such and such a place" type="html"> <cfdump var="#form#"/> </cfmail>
When sending error messages, I like to include a second cfdump for the CGI area (again, only a special structure), as this may provide some other useful information about the request.
If you have CF 8, you might also want to dump in text format, for example, the following, because it will reduce the size of the message (and, in my opinion, will make the message more readable)
<cfdump var="#form#" format="text">
Note. The format attribute of the CFDump tag was added for CF 8, so you cannot use it in previous versions of ColdFusion.
You mentioned that you were looking for a way to store these errors in a database, and that is a good idea. Instead of rolling your own solution for this, I suggest you check out BugLogHQ . It has been a while and works well for others, including me, and best of all it is FREE and Open Source. This age and widespread use means that it will be less likely to have errors in its own code and probably has more and better features than what you write.
Using BugLogHQ, you donโt have to worry about displaying the error, you just send data to the error log and take care of everything else.