Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Process - Best Practice

Status
Not open for further replies.

TamedTech

IS-IT--Management
Joined
May 3, 2005
Messages
998
Location
GB
Hello guys,

Only a small question and i'm really after your opinions more than anything else.

When dealing with forms such as 'contact forms' or forms for 'submitting articles' and suchlike, do you use 2 seperate files such as form.cfm and formprocess.cfm or do you contain them within a single file and use somthing like CFIF to determine if the form has been submitted and then process the database and mail transactions?

Personally untill this point i've always contained them within a single file and used the CFIF, can anyone present a reason as to why you shouldn't do this?

Thanks,

Rob
 
I've always used two different files. File1 would be the form, and file2 would be the processing code. To me its just cleaner to maintain then anything else.

The only real thing you need to be careful for is that your code does not rrun over and over again when a user hits the browser 'refresh' button. The CFIF's would take care of that, no doubt, but to me, having the actual form and the processing code on one page is too cluttered. I like my code to be clean so that when I go back to look at it months (or years) later I know what it was intended for.

____________________________________
Just Imagine.
 
On a very small from I will somtimes make one file.

Generaly I will do aForm_frm.cfm and aForm_act.cfm

Some people say a form should be submited directly to a cfc.

however you do it, make sure it fits your overall practices and standards.

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
I use both methods depending on what I am trying to accomplish, however when I use single page forms/processes I also dislike clutter ... so I usually write the actions etc in a separate file(s) and place them in the main page using CFINCLUDE.

That way, if I have to fix something I only need to deal with the actual action coding and not shuffle through the entire code of a single page.

 
Thanks for that guys,

I do tend to modularize my site with includes quite alot, and i've only started working with CFC's but i can see your point Kevin.

Thanks Guys,

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top