Jump to content

form radio button values = emails


kimeee

Recommended Posts

I have set up a "Leave of Absence Request" form with HTML and PHP. When filled out and sent, it sends a copy to me.

They (my superiors) have also asked if I can set it up so that when a user clicks on a radio button for a specific department, a separate email will be sent to that dept, as well as the email to me.

I know this must be possible. I have tried many ways and have had no luck so far.

Is there anyone out there that can help me?
Link to comment
https://forums.phpfreaks.com/topic/11355-form-radio-button-values-emails/
Share on other sites

You can use a check box instead of the radio button like this

Example check box
[code]
<input type="checkbox" name="Department_name" value="Yes" /> Department Name
[/code]

in you php, you just need to add the extra email address to the "To"
[code]
$to = "[email protected]";
if ($_POST['Department_name'] == "Yes"){
     $to .= ", [email protected]";
}
[/code]

Let me know if you need radio buttons and an example of your form if you need more help.
nogray: i need to set it up with 4 radio buttons with 4 different emails for each button. how would this work? with elseif?

thanks!

[!--quoteo(post=380779:date=Jun 6 2006, 05:15 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ Jun 6 2006, 05:15 PM) [snapback]380779[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You can use a check box instead of the radio button like this

Example check box
[code]
<input type="checkbox" name="Department_name" value="Yes" /> Department Name
[/code]

in you php, you just need to add the extra email address to the "To"
[code]
$to = "[email protected]";
if ($_POST['Department_name'] == "Yes"){
     $to .= ", [email protected]";
}
[/code]

Let me know if you need radio buttons and an example of your form if you need more help.
[/quote]
you can use something like this
[code]
<input type="radio" name="Email" value="Dep1" /> Dep1
<input type="radio" name="Email" value="Dep2" /> Dep1
<input type="radio" name="Email" value="Dep3" /> Dep1
<input type="radio" name="Email" value="Dep4" /> Dep1
[/code]

and your php
[code]
$to = "[email protected]";
if ($_POST['Email'] == "Dep1"){
     $to .= ", [email protected], [email protected], [email protected], [email protected]";
}
else if ($_POST['Email'] == "Dep2"){
     $to .= ", [email protected], [email protected], [email protected], [email protected]";
}
else if ($_POST['Email'] == "Dep3"){
     $to .= ", [email protected], [email protected], [email protected], [email protected]";
}
else {
     $to .= ", [email protected], [email protected], [email protected], [email protected]";
}

[/code]

Hope this helps you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.