insert record and mail it with cfmail
Hi Everyone,
Thanks in advance for any and all help! I am pretty good with Macromedia but I created 2 pages before and lost them, now I can not re-create them, to work anyway.
First, I am using Dreamweaver MX 2004 and Coldfusion MX 7
Before: I had a simple Contact Us page, when submitted, it entered the form data into my access database and sent me an email using cfmail. The insert record behavior was on the contact page and cfmail was embedded in the thank you page and it worked great.
I lost these pages and had to redo the site...
Now: I made the same 2 pages as described above (or so i thought). I started with just the cfmail on the thankyou.cfm page and the email is sent to me. I then added the insert record behavior to the contact page and it still sends the mail but does not insert the record into the database.
In the insert record behavior box, on the form page, I had the thankyou.cfm page listed in the "After inserting, go to" field, that worked fine to send the mail but did not insert the record. I removed the thankyou.cfm from that field and left it blank, now it inserts the record into the database but does not send the mail, obvisouly because it is not going the thankyou.cfm page with the cfmail tag. I tried adding it again and checked the " Pass original query" box which inserted: #CurrentPage#?#CGI.QUERY_STRING# which also inserts the record into the database but still does not send the mail. I have messed around with some differant things but nothing is working, I know it is something small that I am missing because I did once, have this working.
One error I receive is Element BMAIL is undefined in FORM, this tells me that the information is going to the databse and clearing somehow and not being passed to the thankyou.cfm page to be sent out as mail.
If you know of something I may be missing, your help would greatly be appreciated! I am simply trying to enter data into my access database and also have it mail the form data at the same time, can get one or the other working but not both at same time.
Thanks again in advance,
Don
CFMAIL PAGE: This works fine until I add the insert record behavior on the contact page.
<cfmail
server="mail.xxx.com"
from="info@xxx.com"
to="#Form.bmail#"
subject="Brochure Request">
Thank you #Form.bname# for your interest in our site!
Attached you will find our latest brochure.
Thank you and have an great day!
<cfmailparam file="http://www.xxx.com/attachments/brochure1.pdf">
<cfmailparam file="http://www.xxx.com/attachments/brochure2.pdf">
</cfmail>
CONTACT PAGE:
<cfset currentpage="GetFileFromPath"(GetTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "brochure">
<cfquery datasource="ie">
INSERT INTO brochure (bname, bmail) VALUES (
<cfif IsDefined("FORM.bname") AND #FORM.bname# NEQ "">
'#FORM.bname#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.bmail") AND #FORM.bmail# NEQ "">
'#FORM.bmail#'
<cfelse>
NULL
</cfif>
)
</cfquery>
<cflocation url="#CurrentPage#?#CGI.QUERY_STRING#">
</cfif>
Comments
Same issue here...
Hi, i know it has something to do with the:
<cflocation url="#CurrentPage#?#CGI.QUERY_STRING#">
Because of that method you don't receive formvalues anymore.
You have to work with something like sessions or parameters, but i also don't know how and what....
You must me logged in to write a comment.