Processing User Input in HTML mailto - Newbie

Discussion in 'HTML' started by M, Nov 11, 2006.

  1. M

    M Guest

    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:?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, Nov 11, 2006
    #1
    1. Advertising

  2. ..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
     
    Michael Fesser, Nov 11, 2006
    #2
    1. Advertising

  3. "Michael Fesser" <> wrote in message
    news:...
    > .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


    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>
     
    Andrew Bailey, Nov 12, 2006
    #3
  4. Andrew Bailey wrote:
    > "Michael Fesser" <> wrote in message
    > news:...
    >> .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

    >
    > 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?

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Nov 12, 2006
    #4
  5. ..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
     
    Michael Fesser, Nov 12, 2006
    #5
  6. M

    M Guest

    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.....



    Michael Fesser wrote:
    > .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, Nov 12, 2006
    #6
  7. M wrote:
    > 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...

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Nov 12, 2006
    #7
  8. M

    wayne Guest

    M wrote:
    > 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
     
    wayne, Nov 16, 2006
    #8
  9. wayne wrote:
    > M wrote:
    >> 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" />

    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.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Nov 16, 2006
    #9
  10. M

    wayne Guest

    Jonathan N. Little wrote:
    > 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
     
    wayne, Nov 16, 2006
    #10
    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. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    541
    Michael Foord
    Sep 17, 2004
  2. Thomas Gagne
    Replies:
    2
    Views:
    359
    Robert Klemme
    Mar 15, 2013
  3. Sven
    Replies:
    0
    Views:
    101
  4. Arnaud Delobelle

    Re: Processing user input as it's entered

    Arnaud Delobelle, Mar 26, 2013, in forum: Python
    Replies:
    0
    Views:
    97
    Arnaud Delobelle
    Mar 26, 2013
  5. Sven
    Replies:
    0
    Views:
    117
Loading...

Share This Page