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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems parsing form data 2

Status
Not open for further replies.

WebGodiva

Technical User
Joined
Jun 21, 2000
Messages
263
Location
US
I have a form that takes all input from the user and sends and email (second form with cfmail tag in it) and emails the data to several users.
My question is, when I get the data in the email it doesn't contain the field labels and is not parsed correctly (no line breaks).

Is there a way to set it up so it only sends the information actually completed (not all fields) and it shows the labels for the fields it does send with the data being parsed (with line breaks). I've gone through two different CF books and can't find the answer anywhere.

Thanks for your help. Hope this helped!
 
You could try this:

<cfset message=&quot;&quot;&quot;>
<cfloop list=&quot;#form.fieldnames#&quot; index=&quot;field&quot;>
<cfset message = message & field & &quot; : &quot; & evaluate(&quot;form.#field#&quot;) & chr(13) & chr(10)>
</cfloop>

It loops over the submitted formfields and makes one variable called message which can be mailed.

webron
 
Looks great, one problem - I keep getting an invalid parser error.

Should this go in the entry page or the results page?

Thanks Hope this helped!
 
Sorry....
one quote too many

<cfset message=&quot;&quot;>
<cfloop list=&quot;#form.fieldnames#&quot; index=&quot;field&quot;>
<cfset message = message & field & &quot; : &quot; & evaluate(field) & chr(13) & chr(10)>
</cfloop>

works with me.
This should go on the resultpage.

 
The evalute() function in ColdFusion is processor intensive and is slower than other methods. I would take webron's code and modify it a little by accessing the FORM fields as an structure, thus avoiding evaluate(). I also added a line so that it will only add fields that have information (per request of original post).

<cfset message=&quot;&quot;>
<cfloop list=&quot;#FORM.fieldnames#&quot; index=&quot;field&quot;>
[COLOR=666666]<!--- Only add if there is information in the field --->[/color]
<cfif Len(Trim(FORM
Code:
[
field
Code:
]
))>

<cfset message = message & field & &quot; : &quot; & FORM
Code:
[
field
Code:
]
& chr(13) & chr(10)>

</cfif>
</cfloop> - tleish
 
Ok, now I'm loosing my mind. I've tried both lines of code from above and all i get is a blank e-mail.

<cfmail to=&quot;jeffreym@site-blauvelt.com,yvonneh@site-blauvelt.com&quot; from=&quot;webmaster@site-blauvelt.com&quot;
subject=&quot;Employee Data Change Form for Review&quot;>

<cfset message=&quot;&quot;>
<cfloop list=&quot;#FORM.fieldnames#&quot; index=&quot;field&quot;>
<!--- Only add if there is information in the field --->
<cfif Len(Trim(FORM[field]))>
<cfset message = message & field & &quot; : &quot; & FORM[field] & chr(13) & chr(10)>
</cfif>
</cfloop>

</CFMAIL>

Is it supposed to go between the cfmail tags? I appreciate all of your help, I just don't understand what is going wrong. When I receive the e-mail, there are spaces where the field names should be and no text at all.

Any ideas would be greatly appreciated. Hope this helped!
 
<!--- build message var --->
<cfset message=&quot;&quot;>
<cfloop list=&quot;#FORM.fieldnames#&quot; index=&quot;field&quot;>
<cfif Len(Trim(FORM[field]))>
<cfset message = message & field & &quot; : &quot; & FORM[field] & chr(13) & chr(10)>
</cfif>
</cfloop>

<!--- mail message var --->
<cfmail
to=&quot;jeffreym@site-blauvelt.com,yvonneh@site-blauvelt.com&quot;
from=&quot;webmaster@site-blauvelt.com&quot;
subject=&quot;Employee Data Change Form for Review&quot;>
#message#
</CFMAIL>

Maybe the #message# in cfmail needs to be between <cfoutput></cfoutput>

Good luck...
 
No webron, you have it. <CFMAIL> take the place of <CFOUTPUT>, CF will actually throw an error if you try to put <CFOUTPUT> tags inside of <CFMAIL> tags. - tleish
 
still receiving a blank e-mail. Should I define the field names in a cfset tag in the form?

Thanks for all of your help. Hope this helped!
 
Hey all, finally got it to work, I included the following line of code right before your statements:

<CFSET FORMstring = &quot;#form.fieldnames#&quot;>

It worked great. THANKS for all of your help. Hope this helped!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top