Ask Experts Questions for FREE Help !
Ask
    alwysAThm's Avatar
    alwysAThm Posts: 4, Reputation: 1
    New Member
     
    #1

    Apr 12, 2008, 09:57 AM
    e-mail and web forms
    How can I make it to where you can select from a dropdown list and have it go to different e-mails
    jthomsonmain's Avatar
    jthomsonmain Posts: 8, Reputation: 1
    New Member
     
    #2

    Oct 16, 2008, 06:56 PM
    Time to dust off the old Form processing script!
    For the sake of my sanity, I am going to assume (In other words, make an of you and me) that you already know how to make HTML forms and PHP scripts to process them. This is the code that needs to go into your HTML File:

    Code:
    <select name = "EmailTo">
          <option value = "[email protected]">[email protected]</option>
          <option value = "[email protected]">[email protected]</option>
          <option value = "[email protected]">[email protected]</option>
    </select>
    In the PHP Script, you just 'trim' it like you would any other form variable:
    Code:
    $EmailTo = Trim(stripslashes($_POST['EmailTo']));
    All in all, this is a complete overview of my Source code for a simple email script:

    index.htm
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd">
      <head>
        <title>Example Email Form</title>
        <link href="style.css" rel = "stylesheet" type = "text/css">
      </head>
      
      <body>
        <form method="POST" action="post.php">
        <h1>Example Email Form</h1>
        
        <p>Recipiant Email Address:</p> 
        <select name = "EmailTo">
          <option value = "[email protected]">[email protected]</option>
          <option value = "[email protected]">[email protected]</option>
          <option value = "[email protected]">[email protected]</option>
        </select>
        <br>
        <p>Subject: <input type="text" name="subj"></p>
        <p>Message:</p>
        <textarea name = "msg" rows = "20" cols = "40">Enter Message Here</textarea>
        <p><input type="submit" name="submit" value="Submit"></p>
        <br><br><br><br>
        </form>


    post.php
    Code:
    <?php
    
    $EmailFrom = "[email protected]"; 
    $EmailTo = Trim(stripslashes($_POST['EmailTo'])); 
    $Subject = Trim(stripslashes($_POST['subj'])); 
    $Message = Trim(stripslashes($_POST['msg'])); 
    
    $Body = "";
    $Body .= $Message;
    $Body .= "\n";
    
    $Success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    if ($Success)
    {
      echo "Form Submited";
    }
    else
    {
      echo "ERROR: UNKNOWN";
    }
    ?>
    I have also uploaded the script to my webserver. The email function has been dissabled, but this will show you what it looks like: http://jthomsonmain.server1.cc/dev/examp/mail/mail.htm

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

My NEW mail & Mail To Be Sent are not showing up on AOL 9.0, how do I fix this? [ 6 Answers ]

How do I get my NEW mail and Mail To Be Sent to show up on AOL? I use the AOL 9.1 software, Windows 2000. As you may or may not know, AOL allows several screen names, mail shows up on all other screen names, the problem is with only one screen name. When I am on another screen name and try to...

How do you send email from Oracle Forms? [ 2 Answers ]

Hello How can I send a mail from oracle forms Regards Swapna

How do I mail in my forms to MN couthouse for return of my security deposit ? [ 1 Answers ]

Hello. This year, I moved out of my apartment in May. I gave my required written 30 day notice including my new forwarding mailing address. When I moved out, I had decided to shampoo the carpets and I also out a fresh coat of paint on the walls. I was told I would receive my damage deposit in...

Great Auto Response mail for Employee Suggestion mail [ 1 Answers ]

Hi, As part of HR, I take care of the Suggestion Committee which encourages employees to post their suggestions through mail. The ideas are chosen after a period of 1 month by a pre-designated Committee. For every suggestion, we have to give a positive, motivating response in our...

Where to mail the tax forms? [ 2 Answers ]

Hello, I live in SC and I would like to know where to mail the federal tax forms? The article 519 (? ) gives Philly, PA address, IRS representatives gave me the Austin, TX address and the booklet says to mail it to Atlanta, GA. Help Me!!


View more questions Search