|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
cfmail and HTML interaction
Hello,
I am trying to include a script in my form page which will send both the form information (in HTML inputs) to me, as well a confirmation email to the person who has filled out the form (designated as #form.email#). I am pretty new to coldfusion, so I am not all that familiar with syntax issues and interaction with html form tags and such. First I tried using the cf function in a separate file, which had as the code: <cfmail from= #form.email# to="omalleyl@staff.abanet.org" subject="Live from SEC 2004 Registration" server="192.168.2.201"> Name : #form.name# Firm : #form.firm# Address : #form.address# City : #form.city# State : #form.state# Province : #form.province# Zip Code : #form.zip_code# Country : #form.country# Phone : #form.phone# Fax : #form.fax# Email : #form.email# Registration Category : #form.register# Video Site Request : #form.alternative_video# Telephone Site Request : #form.alternative_tele# Law School Site Request : #form.lawschool_site# Video Quantity (member) : #form.videotape_quantity_member# Video Quantity (nonmember) : #form.videotape_quantity_nonmember# Section Membership : #form.membership# Credit Card Type : #form.card_type# Card Number : #form.cc_num# Expiration Date : #form.exp_date# </cfmail> <cflocation url="http://www.abanet.org/intlaw/thanks.html"> while the application page simply called it by <cfinclude template="livefromsec04.cfm"> <form name="regform" action="livefromsec04.cfm" method="post"> the errors that I got were that the application page could not find the .cfm file, and also that the field #form.email# did not exist. It would suffice simply to write the function in the head of the page with the application, and call the function when the form is submitted, but I don't know the syntax for this. <form name="regform" action="????" method="post"> So I guess what I am asking is how do you define the function in the head of the page, and how do you call it in the action of an html form tag? Or any other simpler way to accomplish this would be great as well.. Thanks in advance for any help. -Liam |
|
#2
|
|||
|
|||
|
And yes, I have looked through the macromedia documentation on this.. but was unsuccessful in finding the problem.
|
|
#3
|
|||
|
|||
|
I think these are two separate issues. If CF is complaining that it can't find a .cfm file (which one can't it find by the way?), then that means that the target of an include, cfmodule, or some similar call is pointing to a file that CF can't find.
If CF is complaining that form.email does not exist, then either there is no form field in the posting form called "email", or you're not posting form variables to the target page at all. Make sure the "action" attribute of your form is pointing to your .cfm file that contains the cfmail code.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
I'll try to explain this in a way that is not confusing to you.
You do not need to include the file 'livefromsec04.cfm' in the page that contains the form. It doesn't work this way in CF. CF is a server side language, and the form has to be submitted to an action page to send the email (not call the code as a function). Also, for the 'server' attribute in your cfmail tag, make sure that it is a valid smtp server. Try this someForm.cfm <form name="regform" action="livefromsec04.cfm" method="post"> <!--- Your form here ---> </form> livefromsec04.cfm <cfmail from= #form.email# to="omalleyl@staff.abanet.org" subject="Live from SEC 2004 Registration" server="192.168.2.201"> Name : #form.name# Firm : #form.firm# Address : #form.address# City : #form.city# State : #form.state# Province : #form.province# Zip Code : #form.zip_code# Country : #form.country# Phone : #form.phone# Fax : #form.fax# Email : #form.email# Registration Category : #form.register# Video Site Request : #form.alternative_video# Telephone Site Request : #form.alternative_tele# Law School Site Request : #form.lawschool_site# Video Quantity (member) : #form.videotape_quantity_member# Video Quantity (nonmember) : #form.videotape_quantity_nonmember# Section Membership : #form.membership# Credit Card Type : #form.card_type# Card Number : #form.cc_num# Expiration Date : #form.exp_date# </cfmail> <cflocation url="http://www.abanet.org/intlaw/thanks.html"> |
|
#5
|
|||
|
|||
|
Thanks for your replies.
I have tried all things suggested and still the element 'email' is undefined in 'form.' Does it matter if it is an html input? Maybe it would work if I changed all my form elements to cfinputs? Is this necessary? And if so... what about the form tag itself? Would cfform be preferable for any reason? Thanks again for responding. |
|
#6
|
|||
|
|||
|
No, using standard form elements vs. using cfform would make no difference. In fact, at runtime the CF engine replaces your cfform tags with standard form elements, it just adds some extra javascript validation, etc.
If you try to run the example code found in the documentation (http://livedocs.macromedia.com/cold...a.htm#wp2355015), does it work? If that doesn't work, post or attach your form page and your cfmail page for us to look at. |
|
#7
|
|||
|
|||
|
Hidden Fields
You need to input some simiar hidden fields that correspond to the form fields that you are sending the the cfm script that is processing the form.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-pta.htm#wp2355015 <form action = "cfmail.cfm"> <pre> TO: <input type = "Text" name = "MailTo"> FROM: <input type = "Text" name = "MailFrom"> SUBJECT: <input type = "Text" name = "Subject"> <hr> MESSAGE BODY: <textarea name ="body" cols="40" rows="5" wrap="virtual"></textarea> </pre> <!--- establish required fields ---> <input type = "hidden" name = "MailTo_required" value = "You must entera recipient"> <input type = "hidden" name = "MailFrom_required" value = "You mustenter a sender"> <input type = "hidden" name = "Subject_required" value = "You must entera subject"> <input type = "hidden" name = "Body_required" value = "You must entersome text"> <p><input type = "Submit" name = ""> </form> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > cfmail and HTML interaction |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|