Skip to main content
Inspiring
November 11, 2008
Question

Create new random password

  • November 11, 2008
  • 3 replies
  • 393 views
Hi,

I use PHP and MySQL within Dreamweaver
I want my client to be able to generate a new random password for a new member.

How should I do this?
Create a list of random passwords or
can I create it on the fly while registering a new member?
I don't want the new member to create his own password.




Thanks to all people contributing to this forum.
I learned a lot here allready.

I hope you can also help me out with this one.

Jos
This topic has been closed for replies.

3 replies

Inspiring
November 11, 2008
Good luck!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"arnhemcs" <webforumsuser@macromedia.com> wrote in message
news:gfc37b$neb$1@forums.macromedia.com...
> Thanks.
>
> I'll try it out
> I am not really a developer so I must have a good look at your code.
> I'll come back here to let you now.
>
> Jos

Inspiring
November 11, 2008
Thanks.

I'll try it out
I am not really a developer so I must have a good look at your code.
I'll come back here to let you now.

Jos
Inspiring
November 11, 2008
> can I create it on the fly while registering a new member?

That would be the best way.

I have used this to produce random, 8 character passwords (the database part
is to make sure that they are unique) -

function randomkeys($length)
{
$pattern =
"234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<($length);$i++)
{
if(isset($key))
$key .= $pattern{rand(0,strlen($pattern)-1)};
else
$key = $pattern{rand(0,strlen($pattern)-1)};
}
return $key;
}

mysql_select_db($database_selectData, $selectData);
$query_rsPasswords = "SELECT contactPassword FROM tblcontactdata";
$rsPasswords = mysql_query($query_rsPasswords, $selectData) or
die(mysql_error());
$row_rsPasswords = mysql_fetch_assoc($rsPasswords);
$totalRows_rsPasswords = mysql_num_rows($rsPasswords);

$masterList=array();

$passwords=array();
$rsPasswordList = mysql_query("SELECT contactPassword FROM
tblcontactdata",$selectData)
or die(mysql_errno()." : ".mysql_error());
while ($rec = mysql_fetch_row($rsPasswordList)){
$passwords[] = $rec[0];
}
$unique = false;
while ($unique === false) {
$temp = randomkeys(8); // this is generating a random 8-character p/w
if(!in_array($temp, $passwords)) {
$newPassword = $temp;
$unique = true;
}
}

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"arnhemcs" <webforumsuser@macromedia.com> wrote in message
news:gfbo17$9er$1@forums.macromedia.com...
> Hi,
>
> I use PHP and MySQL within Dreamweaver
> I want my client to be able to generate a new random password for a new
> member.
>
> How should I do this?
> Create a list of random passwords or
> can I create it on the fly while registering a new member?
> I don't want the new member to create his own password.
>
>
>
>
> Thanks to all people contributing to this forum.
> I learned a lot here allready.
>
> I hope you can also help me out with this one.
>
> Jos
>