Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > email selection on a form

Reply
Thread Tools

email selection on a form

 
 
scpirin
Guest
Posts: n/a
 
      11-06-2003
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



 
Reply With Quote
 
 
 
 
Adrienne
Guest
Posts: n/a
 
      11-06-2003
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
 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      11-06-2003
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

 
Reply With Quote
 
scpirin
Guest
Posts: n/a
 
      11-06-2003

"Toby A Inkster" <> wrote in message
news. ..
> 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
>



 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      11-06-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
selection structure nested within another selection structure 4Ankit@gmail.com Javascript 1 12-07-2006 11:47 AM
JTable with row selection, but no cell selection Simon Niederberger Java 2 01-07-2005 04:17 PM
JS comparing innerHTML to text selection (window.getSelection() /document.selection) Andrew Crowe HTML 1 09-13-2004 02:22 PM
How to change a range selection to text selection? Loebb Javascript 0 02-23-2004 02:12 PM
HOWTO autopost the selection list upon selection curiousity ASP .Net Mobile 0 11-21-2003 12:57 AM



Advertisments