Jump to content

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 = "your_email@domain.com";
if ($_POST['Department_name'] == "Yes"){
     $to .= ", department_email@domain.com";
}
[/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 = "your_email@domain.com";
if ($_POST['Department_name'] == "Yes"){
     $to .= ", department_email@domain.com";
}
[/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 = "your_email@domain.com";
if ($_POST['Email'] == "Dep1"){
     $to .= ", dept1_email@domain.com, dept1_email@domain.com, dept1_email@domain.com, dept1_email@domain.com";
}
else if ($_POST['Email'] == "Dep2"){
     $to .= ", dept2_email@domain.com, dept2_email@domain.com, dept2_email@domain.com, dept2_email@domain.com";
}
else if ($_POST['Email'] == "Dep3"){
     $to .= ", dept3_email@domain.com, dept3_email@domain.com, dept3_email@domain.com, dept3_email@domain.com";
}
else {
     $to .= ", dept4_email@domain.com, dept4_email@domain.com, dept4_email@domain.com, dept4_email@domain.com";
}

[/code]

Hope this helps you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.