choosing recipients in a mail form

He has: 688 posts

Joined: Feb 2001

I've got FormMail and form-2-mail. In general it doesn't matter what kind of form mail processor I'm using but what I want to do is have the person filling out the form choose which person or email address they want the form mail to be sent to. The processing scripts I mentioned seem to require recipients predetermined in a separate file (to hide the address from the user). I can add multiple addresses but I don't think I can make it a variable determined by the user. Any suggestions? Is there a better script for me to use that may help with this, or can this be overcome with a bit of script altering?

Thanks.Smiling

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

What about a drop-down combo list thingy? <-- lol sorry don't know what it's called,

edit: by the way i'm referring to those boxes at the bottom of the page that lets you choose which forum you wnat to go to Laughing out loud

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

SELECT boxes and you could ostensibly set them as a variable and have it read into the script. The only problem with that is it will allow for harvesting unless you turn it around and set the SELECT values to something arbitrary (a1, a2, a3) and have those values set in the script.

He has: 688 posts

Joined: Feb 2001

I now figured out how to go about this within my script but I've got one simple problem. I will need to set the variable in php by saying "if 'A' is chosen in the dropdown menu, then use appropriate email address" How do I set a php variable in a dropdown menu (before it posts to the cgi script)?

Busy's picture

He has: 6,151 posts

Joined: May 2001

[email protected]
[email protected]

<?php
if ($email_form == "a") {
$sent_to = "[email protected]";
} else if {
$email_form == "b") {
$sent_to = <a href="mailto:[email protected]" class="bb-email">two@email.com</a>";
} else {
$sent_to = "default@email.com"; }
?>

this is just a really quick example, a switch option would probably be better. the form would have a value next to the email address, in this example I used "a" and "b" if none were chosen it would use [email protected] or you could set up an validation section to make sure it went somewhere.
the variable $sent_to is what you pass on.
why are you using a cgi scrip as well? PHP has the mail() function you can use

He has: 688 posts

Joined: Feb 2001

Thanks! That seems simple enough, even for me. My home computer is in the shop right now but I'll give that a shot as soon as I get it back. Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.