Processing User Input in HTML mailto - Newbie

M

M

Hi,

I have searched various news groups and i know i can use the mailto in
the way below by hardcoding what it should say. Is it possible without
using (asp or cgi) any scripting to pass the contents of user input in
text boxes into the subject and body field to send as an email????????


Yes this works but.....how do i pass user filled information into this
<form name "theform" action="MAILTO:[email protected]?subject=How do i
read info from subject text box and replace this with it&body=Any Help
will be appreciated"
method="post"
enctype="text/plain" >


Any help will be appreciated.
Thanks
M
 
M

Michael Fesser

..oO(M)
I have searched various news groups and i know i can use the mailto in
the way below by hardcoding what it should say.

You cannot use a 'mailto' in a form's action, because it's completely
undefined and will fail in many cases.
Is it possible without
using (asp or cgi) any scripting to pass the contents of user input in
text boxes into the subject and body field to send as an email????????

Form processing always requires a server-side script.

Micha
 
A

Andrew Bailey

Michael Fesser said:
.oO(M)


You cannot use a 'mailto' in a form's action, because it's completely
undefined and will fail in many cases.


Form processing always requires a server-side script.

Micha

Here ya go...

(Remember to scamble the mailto: and your domain name) Make an error and
success page too ;)

Andy


<html>
<head>
<title>Transfer Form data to email client</title>

<script type="text/javascript">
<!-- TRANFER FORM TO EMAIL CLIENT
function sendmymail(){
var firstname= document.getElementById('first').value;
var lastname= document.getElementById('last').value;
var mysubject= document.getElementById('subject').value;
var myto=
document.getElementById('dept')[document.getElementById('dept').selectedIndex].value;
var mybody= document.getElementById('emailbody').value;
if (firstname==''){
parent.location="contact us error page.html";
} else if (lastname==''){
parent.location="contact us error page.html";
} else if (mysubject==''){
parent.location="contact us error page.html";
} else if (mybody==''){
parent.location="contact us error page.html";
} else {
document.location.href="mailto:"+ myto+"@yourdomian.com"?subject="+
mysubject +"&body="+ mybody +"%0D%0A%0D%0AFrom "+ firstname +" " + lastname;
parent.location="contact thankyou page.html";
}
}
// - End of JavaScript - -->
</script>

</head>
<body>

<form method="get" id="the id" name="myform">

Your First Name: <input type="text" name="first" id="first" maxlength="30">
<br>
Your Last Name: <input type="text" name="last" id="last" maxlength="30">
<br>
Subject: <input type="text" name="subject" id="subject" maxlength="60">
<br>
Department: <select name="dept" id="dept">
<option value="sales">Sales</option>
<option value="support">Support</option>
<option value="admin">Admin</option>
<option value="order">Order</option>
<option value="delivery">Delivery</option>
<option value="warranty">Warranty</option>
<option value="privacy">Privacy</option>
<option value="cancellation">Cancellation</option>
<option value="personnel">Personnel</option>
</select>
<br>
Your Message: <textarea cols="35" rows="9" name="emailbody"
id="emailbody"></textarea>
<br>
Submit: <input type="submit" value="Submit" name="Submit"
onclick="sendmymail();" title="Click here to SUBMIT your email">

</form>
</body>
</html>
 
J

Jonathan N. Little

Andrew said:
Here ya go...

(Remember to scamble the mailto: and your domain name) Make an error and
success page too ;)

Andy


<html>
<head>
<title>Transfer Form data to email client</title>

<script type="text/javascript">
<!-- TRANFER FORM TO EMAIL CLIENT
function sendmymail(){
var firstname= document.getElementById('first').value;

<snip the "good try" effort>

And what happens on a computer where no pop email accounts are setup,
i.e., hotmail or yahoo mail account only, eh?
 
M

Michael Fesser

..oO(Jonathan N. Little)
<snip the "good try" effort>

And what happens on a computer where no pop email accounts are setup,
i.e., hotmail or yahoo mail account only, eh?

Additionally it's invalid code.

Micha
 
M

M

Thats a good point, the user may not have a pop 3 account set up and
the java script did not work....

Any suggestions on how to do this form submission....???

I'm sure there are solutions out there in the user groups and obviously
im not looking in the right place....i would appreciate some useful
search tips and if you could also point me towards the right groups for
html....even better would be a solution....as ive been attempting this
form submission for ages :-<

Help me.....
 
J

Jonathan N. Little

M said:
Thats a good point, the user may not have a pop 3 account set up and
the java script did not work....

Any suggestions on how to do this form submission....???

Yes, the proper way to use this is with a server-side script and does
not involve the sender's email client.

<form name "theform"
action="TheScriptOnMyServerThatSendAnEmailToMeDirectly.php" ...

There are many out there, just search for ones that are *secure* and
cannot be used as spam relays... Others here may have some suggestions
for you...
 
W

wayne

M said:
Thats a good point, the user may not have a pop 3 account set up and
the java script did not work....

Any suggestions on how to do this form submission....???

I'm sure there are solutions out there in the user groups and obviously
im not looking in the right place....i would appreciate some useful
search tips and if you could also point me towards the right groups for
html....even better would be a solution....as ive been attempting this
form submission for ages :-<

Help me.....

I use a formmail from http://www.tectite.com/ and have had good success
with it. The file is quite large as all of the documentation is inside.
It is free and secure.

This is the code I use for the form:

<div id="content">
<h1>Contact Form</h1>
<p>Please fill in the blanks and click on "Submit." </p>
<hr />

<form method="post" action="http://your url here">
<input type="hidden" name="env_report"
value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" />
<input type="hidden" name="recipients" value="your email_*_aol.com" />
<input type="hidden" name="bcc" value="another email_*_yahoo.com" />
<input type="hidden" name="required" value="email:Your email
address,firstname:First Name,lastname:Last Name" />
<input type="hidden" name="derive_fields"
value="realname=firstname+lastname" />
<input type="hidden" name="subject" value="Form Information" />

<fieldset>
<legend>Personal Information:</legend>
<label for="lastname">Please enter your last name:</label>
<input type="text" name="lastname" class="field" tabindex="1" />
<label for="firstname">Please enter your first name:</label>
<input type="text" name="firstname" class="field" tabindex="2" />
<label for="address">Please enter your address:</label>
<input type="text" name="address" class="field" tabindex="3" />
<label for="city">Please enter your city:</label>
<input type="text" name="city" class="field" tabindex="4" />
<label for="state">Please enter your state:</label>
<input type="text" name="state" class="field" tabindex="5" />
<label for="phone">Please enter your phone number:</label>
<input type="text" name="phone" class="field" tabindex="6" />
<label for="email">Please enter your email address:</label>
<input type="text" name="email" class="field" tabindex="7" />
</fieldset>

<fieldset>
<legend>Subject:</legend>
<label for="topic">Broken link</label>
<input type="radio" name="topic" value="Broken link" />
<label for="topic">Comment</label>
<input type="radio" name="topic" value="Comment" />
<label for="topic">Question</label>
<input type="radio" name="topic" value="Question" />
<label for="topic">Other</label>
<input type="radio" name="topic" value="Other" checked="checked" />
</fieldset>

<fieldset>
<legend>Please enter your message:</legend>
<textarea name="mesg" rows="10" cols="50"></textarea>
</fieldset>

<fieldset>
<input type="submit" value="Submit" class="button" /><input type="reset"
value="Reset" class="button" />
</fieldset>
</form>
<!--
Please support the ongoing development of FormMail and our other
freeware products by keeping the following text on your form
(or placing it elsewhere on your website). Thanks!
-->
<p class="copy">This form and its free
<a href="http://www.tectite.com/">FormMail</a>
processor supplied by www.tectite.com, creators of
software <a href="http://www.tectite.com/">copy protection</a>.
</p>
</div>

--
Wayne
http://www.glenmeadows.us
With or without religion, you would have good people doing good things
and evil people doing evil things. But for good people to do evil
things, that takes religion.
—Steven Weinberg
 
J

Jonathan N. Little

wayne said:
I use a formmail from http://www.tectite.com/ and have had good success
with it. The file is quite large as all of the documentation is inside.
It is free and secure.

This is the code I use for the form:

<div id="content">
<h1>Contact Form</h1>
<p>Please fill in the blanks and click on "Submit." </p>
<hr />

<form method="post" action="http://your url here">
<input type="hidden" name="env_report"
value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" />
<input type="hidden" name="recipients" value="your email_*_aol.com" />
<input type="hidden" name="bcc" value="another email_*_yahoo.com" />
WHOA! Do not use such a script that has you put the send to email
address in a hidden file!!! An absolute spam relay form! The send to
address should either be hard-coded in the server-side script or pulled
for a configuration file not accessible to the public. To OP *do not*
use such a script.
 
W

wayne

Jonathan said:
address in a hidden file!!! An absolute spam relay form! The send to
address should either be hard-coded in the server-side script or pulled
for a configuration file not accessible to the public. To OP *do not*
use such a script.

If you noticed, the email has characters that are replaced on the
server. In addition, the allowed addresses are hardcoded in the
formmail script, server side. You cannot change the address in the form
and have it go any where else except those addresses or domains (if you
have many addresses at one domain) selected by you. Any one attempting
this will generate a message to the administrator, complete with IP
address of offending client. Too many attempts allows you to block the
domain.

There is also an option to place all of the addresses in a configuration
file so none are in any way visible. I just took the easy way out.

You could download the file and examine the code yourself (heavily
commented so you know exactly what is going on).

Regards,

--
Wayne
http://www.glenmeadows.us
With or without religion, you would have good people doing good things
and evil people doing evil things. But for good people to do evil
things, that takes religion.
—Steven Weinberg
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top