简体   繁体   中英

Parsing user data into &body attribute of mailto form

I have this script:

function calculate(){

passworda = document.password1.user1.value.toLowerCase()
passwordb = document.password1.pass1.value.toLowerCase()

var user = 1
var pass = 1

for(d=0;d<passwordb.length;d++) {
pass*= passwordb.charCodeAt(d);
}
for(e=0;e< passworda.length; e++) {
user *= passworda.charCodeAt(e);
    }
      document.password1.outputuser1.value = user;
      document.password1.outputpass1.value = pass;
}

and this form:

<form name="password1" enctype="text/plain" method="get" action="mailto:myemail@mydomain.com?subject=Register&body=A new user has registered with your form. Their username is ' +outputuser1+ ' and their password is ' +outputpass1+ '">
Username:<input type="text" name="user1" />
Password:<input type="password" name="pass1" />
<input type="submit" value="Register" onclick="calculate()" />
<input type="reset" value="Reset" />
</form>

What I want to do is when a user fills out this form and hits submit, it emails me with their encrypted username and password, replacing

&body=A new user has registered with your form. Their username is ' +outputuser1+ ' and their password is ' +outputpass1+ '"

with

&body=A new user has registered with your form. Their user name is JOHNSMITH and their password is 123456"

when the form gets submitted. I'm not getting any javascript errors, but when the email window opens, the body and subject are blank.

Can anyone help get this working please? Many thanks in advance!

Forms with mailto: uris are too poorly supported for use on the WWW.

If you want to collect data with a form then you need to use an HTTP(S) URI as the action, and process submitted data on the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM