Form to E-mail / E-mail from Forms
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.
Learn More
Subtitles of the Movie
We are now going to take a look at the SUMA Contact Us form and this has actually been already set up for you so I have time to talk through and familiarize you with the code. Inside this particular form there are three pages that are actually creating the entire process. So let me put this into the browser so you can see what it looks like from a user standpoint and then we will come back and look at some of the code. So I'll put it out in the browser, I'm going to kind of cheat and use the Populate Form Fields here, click Contact SUMA. You can see I filled it out, I clicked the Submit button, the user is sent to this Thank You page and there is a query string sent to the Thank You page called emailed and that is going to make sure that I can't get to this Thanks page without having submitted the form. So, let's go back to the form and take a look at what we have. So I'll move into Code view. This is our basic Template using the Header and Footer section as Includes. Then we have a ColdFusion form and this form is set up with an Action to another page, this E-mail Action. I didn't have to do that, but the reason I did was to make it easier for you to be able to see which is the form, which is the action - I just thought it would be a little clearer from your standpoint, so we do have a separate Action page. Within this I am using ColdFusion Form Fields, giving a message, so it does require validation - I didn't show you that piece so I'll put it back in the browser and if I don't put information in you can see Through E-mail Address is required. So that is the message that pops up as we've done with other ColdFusion forms throughout the course. This is going to validate when the user clicks the Submit button, so that's really the only coding, so to speak, on the form. Our basic subject drop-down is not coming from a database, this is purely static options. The Thanks page, which you saw, is simply our form with some thank you information on it, so that is no big deal. I have a little note up here talking about we want to make sure that that Emailed variable is attached as a query string, if not the user will end up back at the form. So the idea is, we don't want the user to access the Action or Thanks page without having submitted the form, so both of these pages will redirect them back to our form here if they immediately get to these pages without submitting the form. So, the Action page is where all the action is, literally and so let's take a look at that. We're testing to make sure that the Submit button has been checked on the form; if it has, this is using the CFMAIL Tag to mail, this is where you would put your E-mail address, this is coming from the E-mail in the form that the user fills out, this User Name and Password you may or may not need, depending upon your E-mail system and then we just have this E-mail putting into the main message area the information coming from the form. The Customer Department and Comment, these are separate items in the form. We want to make sure that the user did something before we try and print them out, so we have a not is defined in here for that particular form field. If it's not defined we are setting a cfparam with a default value for each of those. That way, we never get an error if we try and use those form fields. Basically the user is getting sent to the Thank You page with that Emailed URL Variable if they submitted the form and the E-mail went out, otherwise they are going back to the form itself, meaning they got to this page without clicking the Submit button and we don't want that to happen so we will send them back to the form. Work with these three pages. Make sure you plug in your SMTP Address in the ColdFusion Administrator in order to actually send the E-mail. Obviously you also have to be on the Internet in order to send an E-mail. So, go ahead and plug these in and play with them as you will. These are the three pages that we are working with for the SUMA website in order to take form information from the user and have that form information sent to us as SUMA through an E-mail Address.
Tutorial Information
| Course: | Adobe ColdFusion 8 |
| Author: | Candyce Mairs |
| SKU: | 34093 |
| ISBN: | 1-936334-05-4 |
| Release Date: | 2010-02-26 |
| Duration: | 8 hrs / 112 lessons |
| Work Files: |
Yes |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 