Sending a form via email to a dynamically selected email address. Is this possible?

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 28, 2015   (RSS)

By JeffC - October 28, 2015

I would like to send the contents of a form to a dynamically selected email address.

Below is what I have so far. The website visitor selects North or South from a dropdown and this is sent to sales@domain.co.uk.

I would to expand this setup so that the email addresses change dynamically. So if the website visitor selects 'North' the email will be sent to north@domain.co.uk AND sales@domain.co.uk. If they select 'South' it will be sent to south@domain.co.uk AND sales@domain.co.uk.

<div class="form-group">
<label class="control-label" for="area">Are you on the North or South of the river</label> 
<select class="form-control" name="area">
<option selected="selected">Please select one</option> 
<option value="North" <?php selectedIf(@$_REQUEST['North'], 'North') ?>>North</option>
<option value="South" <?php selectedIf(@$_REQUEST['South'], 'South') ?>>South</option>
</select>
</div>
</div>

// send email alert
$to="sales@domain.co.uk"; 
$subject="A new form has been added to the database"; 
if(@$_REQUEST['info_request']){$_REQUEST['info_request']=1;}else{$_REQUEST['info_request']=0;} 

__TEXT__;
$from="FROM: form@domain.co.uk";
mail($to,$subject,$message,$from);

Area: {$_REQUEST['area']}

// display thanks message and clear form
$successAlerts = "Thanks, we have received your form.";
$_REQUEST = array();
}
}

Jeff