I'll be posting some usefull code in this thread for anyone who is looking into coldfusion. This thread can be used for a recource on anything Cold Fusion Related. I'll start by posting very basic stuff. Check back, I'll try and add some posts daily, so if you got questions and comments, post back. I'll be adding some cool stuff eventually like google api integration, image resizing, and jquery integration with coldfusion ..so lets start basic !
Code 1.0 - Re-Usable Sendmail Function.
First up, is a general send mail form. People were always coming up to me, telling me they needed a form set up, and I got sick of having to type out every variable in the action statement, so all I did here was create a loop, that looped through all the form fields, and displayed there name, fallowed by the evaluation of the field. At the end , I simply re-located back to a thank you page. All the validation is handled on the previous html, with Javascript, and remember ,you cant have spaces or dashes in the form field names, when naming them, because it will cause an error, if you have a way around this, please share. There is a few ways, like replacing every _ with a space. Anyway, heres the first code of the thread !!
sendmail.cfm
Code Notes: Name form fields what you want to display before what is evaluated. Put this as your action="" on your normal html form.
Code 1.0 - Re-Usable Sendmail Function.
First up, is a general send mail form. People were always coming up to me, telling me they needed a form set up, and I got sick of having to type out every variable in the action statement, so all I did here was create a loop, that looped through all the form fields, and displayed there name, fallowed by the evaluation of the field. At the end , I simply re-located back to a thank you page. All the validation is handled on the previous html, with Javascript, and remember ,you cant have spaces or dashes in the form field names, when naming them, because it will cause an error, if you have a way around this, please share. There is a few ways, like replacing every _ with a space. Anyway, heres the first code of the thread !!
sendmail.cfm
Code Notes: Name form fields what you want to display before what is evaluated. Put this as your action="" on your normal html form.
Code:
<cfoutput>
<CFMAIL SERVER="yourserver" FROM="#form.email#" TO=[EMAIL="email@theemail.com"]email@theemail.com[/EMAIL] SUBJECT="Contact Form From Website!" type="html">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<cfif NOT #TheField# is "SUBMIT">#TheField# - #Evaluate(TheField)#<br /></cfif>
</CFLOOP>
</CFMAIL>
</cfoutput>
<cflocation template="/thankyou.cfm">