Reputation: 227
I have a php mailer that uses emails like this:
$mail->AddAddress('[email protected]');
to send to all emails. What i want to do is create a drop down that has different locations. and based on what location a user selects would send it to different emails for example if a user choose west in a drop down it would send email to [email protected] or if they choose east it would send to [email protected] is it possible to use a drop down and and If statement to achieve this?
<div id="contact_contact">PREFERRED CONTACT:<br>
<select class="element select medium" id="element_5" name="preferred">
<option value="east" >east</option>
<option value="west" >west</option>
<option value="north" >north</option>
<option value="south" >south</option>
</select>
</div>
Upvotes: 0
Views: 598
Reputation: 87
You can do the following:
switch($_POST['preferred']){
case "east": $toAdd = "[email protected]"; break;
case "west": $toAdd = "[email protected]"; break;
}
$mail->AddAddress($toAdd);
Upvotes: 2
Reputation: 61
You can access the value posted from the form and concatenate @email.com
to the value.
Code snippet:
$preferred = $_REQUEST['preferred'];
$email = $preferred.'@email.com';
$mail->AddAddress($email);
Depending on your form method, you can also use $_POST or $_GET
in place of $_REQUEST
Upvotes: 0