email selection on a form

Discussion in 'HTML' started by scpirin, Nov 6, 2003.

  1. scpirin

    scpirin Guest

    How can I create a dropdown menu that offers different email addresses and
    when submit is clicked, emails the form results to the specified email
    address?

    I am pretty sure HTML itself won't do it. Am willing to incorporate ASP or
    PHP.

    thanks,
    scpirin
    scpirin, Nov 6, 2003
    #1
    1. Advertising

  2. scpirin

    Adrienne Guest

    Gazing into my crystal ball I observed "scpirin" <>
    writing in news::

    > How can I create a dropdown menu that offers different email addresses
    > and when submit is clicked, emails the form results to the specified
    > email address?
    >
    > I am pretty sure HTML itself won't do it. Am willing to incorporate
    > ASP or PHP.
    >
    > thanks,
    > scpirin
    >
    >
    >
    >


    ASP - Page 1
    <form method="post" action="form2.asp">
    <fieldset>
    <label for="email">Email Address: </label>
    <!-- If you are getting the email addresses from a database, open a
    recordset here -->
    <select name="email" id="email">
    <!-- Begin looping through your recordset -->
    <option value="">Select an Email Address</option>
    <option value=""></option>
    <option value=""></option>
    <!-- end looping -->
    </select>
    <p style="text-align:center"><input type="submit" value="Submit" /></p>
    </fieldset>
    </form>

    Page 2

    <% dim email

    email = request.form("email")

    newmail.to = email
    newmail.body = "Your message here"
    newmail.send

    %>

    Adjust page 2 to whatever mailing system you are using, CDO, Aspmail, etc.

    --
    Adrienne Boswell
    Please respond to the group so others can share
    http://www.arbpen.com
    Adrienne, Nov 6, 2003
    #2
    1. Advertising

  3. scpirin wrote:

    > How can I create a dropdown menu that offers different email addresses and
    > when submit is clicked, emails the form results to the specified email
    > address?
    >
    > I am pretty sure HTML itself won't do it. Am willing to incorporate ASP or
    > PHP.


    You are right. HTML won't do it.

    In PHP, it would be something like this:

    Form:

    <form action="formhandler.php" method="POST">
    <fieldset>
    <legend>E-mail Form</legend>
    <label>To: <select name="who">
    <option value="a">Al</option>
    <option value="b">Bob</option>
    <option value="c">Chaz</option>
    </select></label><br>
    <label>Subject: <input name="what1"></label><br>
    <label>Body:<br> <textarea name="what2"></textarea></label>
    </fieldset>
    </form>

    formhandler.php:

    <?php
    $who = $_POST['who'];
    if ($who == 'a') { $to = ''; }
    else if ($who == 'b') { $to = ''; }
    else ($who == 'c') { $to = ''; }
    $subj = $_POST['what1'];
    $body = $_POST['what2'];
    if ( mail($to,$subj,$body) ) {
    header('Location: thanks.html');
    } else {
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <title>Error</title>
    <body><h1>Error</h1><p>An unspecified error occurred.</p></body>
    <?
    }
    ?>

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
    Toby A Inkster, Nov 6, 2003
    #3
  4. scpirin

    scpirin Guest

    "Toby A Inkster" <> wrote in message
    news:p...
    > scpirin wrote:
    >
    > > How can I create a dropdown menu that offers different email addresses

    and
    > > when submit is clicked, emails the form results to the specified email
    > > address?
    > >
    > > I am pretty sure HTML itself won't do it. Am willing to incorporate ASP

    or
    > > PHP.

    >
    > You are right. HTML won't do it.
    >
    > In PHP, it would be something like this:
    >
    > Form:
    >
    > <form action="formhandler.php" method="POST">
    > <fieldset>
    > <legend>E-mail Form</legend>
    > <label>To: <select name="who">
    > <option value="a">Al</option>
    > <option value="b">Bob</option>
    > <option value="c">Chaz</option>
    > </select></label><br>
    > <label>Subject: <input name="what1"></label><br>
    > <label>Body:<br> <textarea name="what2"></textarea></label>
    > </fieldset>
    > </form>
    >
    > formhandler.php:
    >
    > <?php
    > $who = $_POST['who'];
    > if ($who == 'a') { $to = ''; }
    > else if ($who == 'b') { $to = ''; }
    > else ($who == 'c') { $to = ''; }
    > $subj = $_POST['what1'];
    > $body = $_POST['what2'];
    > if ( mail($to,$subj,$body) ) {
    > header('Location: thanks.html');
    > } else {
    > ?>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">
    > <title>Error</title>
    > <body><h1>Error</h1><p>An unspecified error occurred.</p></body>
    > <?
    > }
    > ?>
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me - http://www.goddamn.co.uk/tobyink/?page=132



    Thanks much guys.....
    Will work on both formats and see if I can get it to work........

    scpirin
    >
    scpirin, Nov 6, 2003
    #4
  5. scpirin

    Default User Guest

    scpirin wrote:

    > Thanks much guys.....
    > Will work on both formats and see if I can get it to work........



    Make sure your mail handling script doesn't take in an address from the
    form and use it willy-nilly. Otherwise spammers can exploit your script
    to their benefit and likely your sorrow.




    Brian Rodenborn
    Default User, Nov 6, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Niederberger
    Replies:
    2
    Views:
    16,452
    Christian Kaufhold
    Jan 7, 2005
  2. Andrew Crowe
    Replies:
    1
    Views:
    4,444
    Andrew Crowe
    Sep 13, 2004
  3. curiousity

    HOWTO autopost the selection list upon selection

    curiousity, Nov 21, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    260
    curiousity
    Nov 21, 2003
  4. Loebb
    Replies:
    0
    Views:
    193
    Loebb
    Feb 23, 2004
  5. Replies:
    1
    Views:
    202
Loading...

Share This Page