473,470 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems about send automatic email with a random password

9 New Member
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 1954
r035198x
13,262 MVP
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
mohsenhosseini
28 New Member
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.