email notification based on form value

I am looking for at least a starting point for a code that can notify multiple people based on a given response in a form. Everything I am finding is a basic email a single person if a row is added to a database. I need to be able to email different people the form responses if a specific value for a specific field is entered.

Could you elaborate a little more for us?

By the sound of it, you want to email a set of people if response = x. Or email another set of people if response = y. Is this correct?

That is correct. To be exact I have an add edit view delete process that I want to have an email sent out based on the a record being added or changed. There are multiple facilities that will be using the system. A dropdown menu will be given to choose the facility. An example would be is user picks “Facility A” then "[email protected] is sent the form contents.

I’ve got this far…which isn’t very far.

a mixture of an elseif statement where if ($facility="") {echo email code here} elseif ($facility="") {echo email code here}

[php]<?php
if ($a > $b) {
echo “a is bigger than b”;
} elseif ($a == $b) {
echo “a is equal to b”;
} else {
echo “a is smaller than b”;
}
?>[/php]

and a code for email like this
[php]<?php
// the message
$msg = “First line of text\nSecond line of text”;

// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);

// send email
mail("[email protected]",“My subject”,$msg);
?>[/php]

$dropdown_value = $_POST[“your_dropdown”]
if ($dropdown_value==“A”) {
$email_address = "[email protected]";
} elseif ($dropdown_value==“B”) {
$email_address = "[email protected]";
} else {
$email_address = "[email protected]";
}
mail($email_address, “My subject”, $msg);

… Something loosely like that …

OR even better just use the VALUE= in the tags and set them to the actual email address.
Like Fac-AFac-B
And, then, just …
mail($_POST[“your_dropdown”], “My Subject”, $msg); (No need for the IF clauses that way…)

Lots of ways to do it…

Sponsor our Newsletter | Privacy Policy | Terms of Service