Connecting Tech Pros Worldwide Forums | Help | Site Map

Email Form for Website (multiple recipients)

max2008mmm's Avatar
Newbie
 
Join Date: Dec 2008
Posts: 2
#1: Dec 18 '08
I am trying to create a email contact form for our website. I want there to be four fields for a visitor to fill in (name, email address, subject, message). The subject field will be a drop-down box to allow for a variety of purposes for the visitor's message. I know how to do all of this and have the message sent to one address. However, I would like to associate each subject choice to a different email address. I've looked all over the Internet and can't seem to come across with a way to do this. Is there anyone out there that knows how to do this with either PHP, CGI, or JavaScript?

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,664
#2: Dec 18 '08

re: Email Form for Website (multiple recipients)


you could use a switch to select the appropriate email address by the subject. like
Expand|Select|Wrap|Line Numbers
  1. $subject = $_POST['subject'];
  2. switch ($subject)
  3. {
  4.    case "I'm topic 1" : $email = "mail1@host.tld"; break;
  5. // and so on
  6. }
  7. }
alternatively, if you submit the subject by number you can also do
Expand|Select|Wrap|Line Numbers
  1. $num = $_POST['subject'];
  2. $subject = $stored_subjects[$num];
  3. $email = $stored_emails[$num];
(to name only some possibilities)

regards
Reply

Tags
contact, email, form, multiple, recipients


Similar PHP bytes