Mass enquiry form

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 22, 2012   (RSS)

Hi,
We use cmsadmin to provide advertiser listings for holiday accommodation, while visitors can contact individual advertisers from the listings page, we would like to offer the visitor the ability to send a form based enquiry to multiple or all advertisers in each section. (I suspect that having a dynamic list of advertisers appear to be checked to receive an email could be costly to produce so a simple mail all facility would be sufficient)

With no php programming experience I suspect that what we need to accomplish this is likely to be pretty straight forward but would need someone to create the required code for us.

Any help or advice on how easily this could be accomplished, or potential costs would be appreciated. Our big problem is that we provide the site as a community support initiative and provide advertising on it at a minimal cost to cover admin etc (£1.00per week) so the site doesnt generate any real profit which could be used to fund such development so availible funding is minimal to say the least.

Thanks in advance for any help provided.

Re: [willydoit] Mass enquiry form

By Jason - February 21, 2012

Hi,

The biggest part of this will be getting your list of advertisers. Are they all stored in the same section? Will the form simply send to all of them, or will it have to only send to some of them?

Once you get your advertiser records, you need to combine all their emails into a comma separated list.

For example:

$toEmailList = join(",", array_unique(array_pluck($advertiserRecords, 'email')));

This code assumes that all the advertiser records you want to send the message to are in a variable called $advertiserRecords, and they have a field called "email" where their email is stored.

After that, you can use the CMS Builder sendMessage() function to send your email. Here is a very basic example:

$mailErrors = sendMessage(array(
'from' => 'me@example.com',
'to' => $toEmailList,
'subject' => "Email Subject",
'text' => "My Message",
));

if ($mailErrors) { die("Error Sending Message: ".$mailErrors); }


Hope this helps get you started
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Mass enquiry form

Hi jason,
Thanks for that, i assume that i would use the normal listing page code before the header of the php page to open the database link etc, then add your first line of code to create the array. The form will be submitted to all the advertisers in the record.

I assume i would then simply create my enquiry form in the usual manner using dreamweavers insert form facilities, I usually use an existing form to mail facility for handling such forms to a single email address, are you saying that cmsb also has a form to mail facility built in which would be implemented automatically just by using your second lot of code or do we use your code aswell as our normal form to mail handler?

If we just use your code, where would i put your second section of code in relation to the <FORM METHOD=POST ACTION= element and what value would i put for action=

Sorry if this is basic stuff we should know.

Also is there any security facility built in which we can implement to avoid abuse from spam bots etc.

Thanks in advance for your help,