SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    contact form to route to different email addresses

    I am looking for a PHP script that will send information from a contact form. I have found many of these, but I want to go a step further. I want to have a drop-down on my contact form where the user can select a subject type and based on that selection, the email submitted will go to a different email address. Any help pointing me in the right direction is appreciated.

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your best bet is to modify a form that you've found to work and are happy with already.

    As a rough guide:
    Code HTML:
    <form>
     
    <label for="subject">Subject: </label>
    <select name="subject" id="subject">
        <option value="0">General Enquiry</option>
        <option value="1">Technical Support</option>
        <option value="2">Partner with us</option>
    </select>
    </form>

    When processing the form change the recipient email based on the subject area selected:
    PHP Code:
    // $_POST['subject'] is 0,1,2 depending on what user selected
    // line up with appropriate email address using the array key
    $email[0] = 'general@example.com';
    $email[1] = 'technical@example.com';
    $email[2] = 'partnerships@example.com';

    //Get preferred address
    if(isset($email[$_POST['subject']])) {
      
    $email $email[$_POST['subject']];
    }
    else 
    $email $email[0]; //if no match, fall-back to general

    // $email is the one to use 
    Make sense?

  3. #3
    Non-Member adstiger's Avatar
    Join Date
    Nov 2008
    Location
    Canada
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you script does not have mail function, please put the complete script here.

  4. #4
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you referring to my code?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •