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

Need to loop thru form responses and email 1

Status
Not open for further replies.

DeZiner

Programmer
May 17, 2001
815
US
Any help is great help!

I am a CF guy, and must create a php script that will loop thruough form fields and send the name value pair via email. Here is what I use in CF
Code:
<cfloop index=&quot;fname&quot; list=&quot;#form.fieldnames#&quot;>
#fname#: #Evaluate(&quot;form.&quot; & fname)#<br>
</cfloop>
this goes in the body of the cfmail call. how can I do the same in PHP. The field names are dynamic, nothing is set. However it is guarenteed that the fields contain valid names (no dashes, quotes, astricks, etc)
DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Something like this, (assuming POST-method input):

foreach ($_POST as $fieldname => $fieldvalue)
{
print $fieldname . ': ' . $fieldvalue . '<br>';
}

Would output them.

Changing the interior line to read:

$message .= $fieldname . ': ' . $fieldvalue . '<br>';

Would append each output in turn to a variable named $message. Want the best answers? Ask the best questions: TANSTAAFL!
 
Thanks for the help. Funny, this worked great on my Win2K box, then I moved it to our unix box, no code change, and started getting the following error. Any thoughts?

Warning: Invalid argument supplied for foreach() in /var/ on line 9

Line 9 seems to be:
foreach ($_POST as $fieldname => $fieldvalue)


DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top