Customized Form Mail Script

6 posts by 2 authors in: Forums > CMS Builder
Last Post: May 22, 2018   (RSS)

By leo - May 18, 2018

Hi Michael,

What is the goal you want to achieve?

Thanks,

Leo - PHP Programmer (in training)
interactivetools.com

By Mohaukla - May 19, 2018 - edited: May 19, 2018

The goal should be to allow the client to add/subtract/edit fields in the system and have them show in the form. The form on the page I'm working on works just fine. But the mail script needs to reflect the same fields.

I need correct code for getting the script to work with the CMS.

Thanks

Michael

Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

By leo - May 22, 2018 - edited: May 22, 2018

Hi Michael,

If I understand it right, you have a form that's generated from reservation_fields and will submit the values based on the dynamic field names. And you want to use those values to generate an email?

If that's the case here is what you need to put the post data into the email body:

foreach ($reservation_fieldsRecords as $record){
 $body .= htmlencode($record['title']) . ': ' . htmlencode($_POST[$record['form_field']]) . "\n";
}

Leo - PHP Programmer (in training)
interactivetools.com

By Mohaukla - May 22, 2018

Hey, thanks Leo!

I need to clarify here.

There are 2 sections that are calling for a loop

#1

foreach ($reservation_fieldsRecords as $record): 
$echo htmlencode($record['title'])=$_POST ['echo htmlencode($record['form_field'])']; 
endforeach

and #2

foreach ($reservation_fieldsRecords as $record): 
$body.='echo htmlencode($record['title']) : '.$echo htmlencode($record['form_field']) ."\n";
endforeach

in which your code seems to apply to the second loop but there is no "_post" in that one

Here is yours:

foreach ($reservation_fieldsRecords as $record){ $body .= htmlencode($record['title']) . ': ' . htmlencode($_POST[$record['form_field']]) . "\n";}

I took out the "_post" and came up with:

foreach ($reservation_fieldsRecords as $record){ $body .= htmlencode($record['title']) . ': ' . htmlencode($record['form_field']) . "\n";}

I tried to apply this logic to the first loop but my program keeps telling me its wrong. Can you format the first loop section and I will test the script?


And a couple questions I have are... 

Does the php ignore the whitespace between some characters? ...  "$body ." or " . htmlencode($record['form_field']) "


Is your code missing something to format the lines correctly in the second loop?...  $body .' to create $body.='Departure City: '.$departure."\n";
I did not see it in there but when I added it my program said there was an error.

Thanks

Michael

Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

By leo - May 22, 2018

Hi Michael,

If you use reservation_fieldsRecords to generate the form fields and their names, and you want to use the posted values to make an email out of that. You don't need the first loop. Just grab the post values and put them into the body variable. And that's what my code does.

If there's an error please post the error so I can figure out what's wrong.

Thanks,

Leo - PHP Programmer (in training)
interactivetools.com