473,382 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problems about send automatic email with a random password

How can I use this random password code, and then insert the password into email which is sent to the user after the registration has been finished?
thx


[HTML]<html>
<head>
<title>javascript: Password Generator</title>

<style type="text/css">
input, select { font-family: Verdana, Arial, sans-serif;
font-size: 16pt;
font-weight: bold;
}
</style>

<script language="JavaScript">

function GeneratePassword() {

if (parseInt(navigator.appVersion) <= 3) {
alert("Sorry this only works in 4.0+ browsers");
return true;
}

var length=8;
var sPassword = "";
length = document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;

var noPunction = (document.aForm.punc.checked);
var randomLength = (document.aForm.rLen.checked);

if (randomLength) {
length = Math.random();

length = parseInt(length * 100);
length = (length % 7) + 6
}


for (i=0; i < length; i++) {

numI = getRandomNum();
if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

sPassword = sPassword + String.fromCharCode(numI);
}

document.aForm.passField.value = sPassword

return true;
}

function getRandomNum() {

// between 0 - 1
var rndNum = Math.random()

// rndNum from 0 - 1000
rndNum = parseInt(rndNum * 1000);

// rndNum from 33 - 127
rndNum = (rndNum % 94) + 33;

return rndNum;
}

function checkPunc(num) {

if ((num >=33) && (num <=47)) { return true; }
if ((num >=58) && (num <=64)) { return true; }
if ((num >=91) && (num <=96)) { return true; }
if ((num >=123) && (num <=126)) { return true; }

return false;
}

</script>

<h2>javascript: Password Generator</h2>

<p><form name="aForm">
<table>

<tr>
<td>Generated Password:<br />
<input type="text" name="passField" value="" size="15"><br /></td>

<td># of chars<br />
<select name="charLen">
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8" selected>8
<option value="9">9
<option value="10">10
<option value="11">11
<option value="12">12
<option value="13">13
<option value="14">14
<option value="15">15
</select>

</td>
</tr>

<tr>
<td><p><input type="checkbox" name="punc" checked> No Punction Marks <br />
<input type="checkbox" name="rLen"> Random Length (6 - 12) <br /></p></td>
<td>&nbsp;</td>
</tr>

<tr><td colspan="2" align="center">&nbsp;</td></tr>

<tr><td colspan="2" align="center">
<p><input type="button" value=" Generate Password " onClick="GeneratePassword()"></p></td>
</tr>
</table>[/HTML]
Mar 14 '07 #1
2 1951
r035198x
13,262 8TB
How can I use this random password code, and then insert the password into email which is sent to the user after the registration has been finished?
thx


<html>
<head>
<title>javascript: Password Generator</title>

<style type="text/css">
input, select { font-family: Verdana, Arial, sans-serif;
font-size: 16pt;
font-weight: bold;
}
</style>

<script language="JavaScript">

function GeneratePassword() {

if (parseInt(navigator.appVersion) <= 3) {
alert("Sorry this only works in 4.0+ browsers");
return true;
}

var length=8;
var sPassword = "";
length = document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;

var noPunction = (document.aForm.punc.checked);
var randomLength = (document.aForm.rLen.checked);

if (randomLength) {
length = Math.random();

length = parseInt(length * 100);
length = (length % 7) + 6
}


for (i=0; i < length; i++) {

numI = getRandomNum();
if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

sPassword = sPassword + String.fromCharCode(numI);
}

document.aForm.passField.value = sPassword

return true;
}

function getRandomNum() {

// between 0 - 1
var rndNum = Math.random()

// rndNum from 0 - 1000
rndNum = parseInt(rndNum * 1000);

// rndNum from 33 - 127
rndNum = (rndNum % 94) + 33;

return rndNum;
}

function checkPunc(num) {

if ((num >=33) && (num <=47)) { return true; }
if ((num >=58) && (num <=64)) { return true; }
if ((num >=91) && (num <=96)) { return true; }
if ((num >=123) && (num <=126)) { return true; }

return false;
}

</script>

<h2>javascript: Password Generator</h2>

<p><form name="aForm">
<table>

<tr>
<td>Generated Password:<br />
<input type="text" name="passField" value="" size="15"><br /></td>

<td># of chars<br />
<select name="charLen">
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8" selected>8
<option value="9">9
<option value="10">10
<option value="11">11
<option value="12">12
<option value="13">13
<option value="14">14
<option value="15">15
</select>

</td>
</tr>

<tr>
<td><p><input type="checkbox" name="punc" checked> No Punction Marks <br />
<input type="checkbox" name="rLen"> Random Length (6 - 12) <br /></p></td>
<td>&nbsp;</td>
</tr>

<tr><td colspan="2" align="center">&nbsp;</td></tr>

<tr><td colspan="2" align="center">
<p><input type="button" value=" Generate Password " onClick="GeneratePassword()"></p></td>
</tr>
</table>
This is a Java forum not a Javascript forum.

Moved to Javascript forum.
Mar 14 '07 #2
hi dear
you have 2 options.

1-you can use the javascript to open the default web client like outlook in the client computer
complete correct code
[HTML]
<html>
<head>
<title>javascript: Password Generator</title>

<style type="text/css">
input, select { font-family: Verdana, Arial, sans-serif;
font-size: 16pt;
font-weight: bold;
}
</style>

<script language="JavaScript">

function GeneratePassword() {

if (parseInt(navigator.appVersion) <= 3) {
alert("Sorry this only works in 4.0+ browsers");
return true;
}

var length=8;
var sPassword = "";
length = document.aForm.charLen.options[document.aForm.charLen.selectedIndex].value;

var noPunction = (document.aForm.punc.checked);
var randomLength = (document.aForm.rLen.checked);

if (randomLength) {
length = Math.random();

length = parseInt(length * 100);
length = (length % 7) + 6
}


for (i=0; i < length; i++) {

numI = getRandomNum();
if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

sPassword = sPassword + String.fromCharCode(numI);
}

setMailLinkHref('myLink','you@yourmail.com','rando m password',sPassword)
document.aForm.passField.value = sPassword

return true;
}

function getRandomNum() {

// between 0 - 1
var rndNum = Math.random()

// rndNum from 0 - 1000
rndNum = parseInt(rndNum * 1000);

// rndNum from 33 - 127
rndNum = (rndNum % 94) + 33;

return rndNum;
}

function checkPunc(num) {

if ((num >=33) && (num <=47)) { return true; }
if ((num >=58) && (num <=64)) { return true; }
if ((num >=91) && (num <=96)) { return true; }
if ((num >=123) && (num <=126)) { return true; }

return false;
}

function setMailLinkHref(elmId,to,subj,msg)
{
oLink = document.getElementById(elmId);
str = 'mailto:'+to+'?subject='+subj+'&body='+msg;
oLink.href = str;
oLink.innerHTML = 'send mail <b>'+msg+'</b>';
}
</script>

<h2>javascript: Password Generator</h2>

<p><form name="aForm">
<table>

<tr>
<td>Generated Password:<br />
<input type="text" name="passField" value="" size="15"><br /></td>

<td># of chars<br />
<select name="charLen">
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8" selected>8
<option value="9">9
<option value="10">10
<option value="11">11
<option value="12">12
<option value="13">13
<option value="14">14
<option value="15">15
</select>

</td>
</tr>

<tr>
<td><p><input type="checkbox" name="punc" checked> No Punction Marks <br />
<input type="checkbox" name="rLen"> Random Length (6 - 12) <br /></p></td>
<td>&nbsp;</td>
</tr>

<tr><td colspan="2" align="center">
<a href="#" id="myLink"></a>
</td>
</tr>

<tr><td colspan="2" align="center">
<p><input type="button" value=" Generate Password " onClick="GeneratePassword()"></p></td>
</tr>
</table>[/HTML]

i think its not great way to do it .i suggest you try to generate and send the random password with server side scripts like php

2-you can use ajax to send this message without refreshing client page with server side sending usage.
Mar 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: | last post by:
Hello, Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But...
6
by: vishal | last post by:
hi i am building aan application which will send mail to user when he registers on my site and i am checking whther the email id is working properly or not by sending his email and then cheking...
3
by: PHP | last post by:
I have a login page, that have this code: It is called from a page with a form and 3 inputs, email, password and autologin. <?PHP mysql_connect("localhost", "user", "psw");...
3
by: zeedan | last post by:
Hi, I appologise if I'm not posting this to the correct group, but I'm having problems starting MySQL server. I need it in order to post a websurvey for a research project I'm doing for a college...
0
by: Adam Carpenter | last post by:
Hello, I am having some problems with these functions which are to be part of the forgotten password system for a website. I am sure it is something simple but I can't see it. I would be...
4
by: vercingetorix52 | last post by:
I'm trying to use a python script to access an embedded computer running linux and connected via a crossover ethernet cable using the following script... ....and I realize the username and...
8
by: Katash | last post by:
Hello, I am new to PHP and am working on a login system for my site, currently supplied passwords are passed to MySQL and stored as md5 hashes, my question is :- seeing as md5 is 1 way only what...
3
by: dtvuser | last post by:
Hi, I'm new to PHP and seem to be having soom problems, I'm getting confused with all the different styles of script writing. I've created a PHP script to submit details to my email but the...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.