473,395 Members | 1,571 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,395 software developers and data experts.

Create passwords for multiple records (PHP/mySQL)

hi

I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.

Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?

A couple of possible complications...

1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -
http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.

2. They've also asked that the password avoids letter 'O' and numner
'0'.

Thanks in advance!
Sep 25 '08 #1
7 2263
wozza wrote:
hi

I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.

Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?

A couple of possible complications...

1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -
http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.

2. They've also asked that the password avoids letter 'O' and numner
'0'.

Thanks in advance!
No standard way, but lots of different ways to generate passwords. Try
googling for

"password generator" php

You'll get lots of ideas.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 25 '08 #2
On 25 Sep, 13:27, wozza <warren...@googlemail.comwrote:
hi

I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.

Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?

A couple of possible complications...

1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.

2. They've also asked that the password avoids letter 'O' and numner
'0'.

Thanks in advance!
So you want to generate random passwords without the letter 0/number 0

A simple solution would be to generate a hash of the data along with a
secret salt - say

$password=str_replace('0', 'g', substr(sha1($data . 's3cr3t'),
0,8)); // sha1 is hex encoded i.e. 0-9,a-f

Or if you want a more random solution with more emphasis on
letters....

$chars=explode(',',"a,b,c,d,e,f,g,h,i,j,k,m,n,p,q, r,t,u,x,y,z,
2,3,4,5,6,7,8,9,!,$,%,&,*,@,#"); // for niceness I've also omitted l
(L) and 1 (one)
shuffle($chars);
$password=substr($chars,0,8);

C.
Sep 25 '08 #3
Message-ID:
<3a**********************************@l43g2000hsh. googlegroups.comfrom
wozza contained the following:
>Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?

A couple of possible complications...

1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -
http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.

2. They've also asked that the password avoids letter 'O' and numner
'0'.

What you are asking is not a major task for a coder and that's the
problem with DW generated code isn't it? You are fine until you want
something a bit different. In this case you may be better off paying
for an hour or so of a coder's time.

For the passwords, there are any number of scripts you could use. I
like to use a randomly chosen keyword (taken from a pool that I create
to suit the website) plus a randomly generated number between 0001 and
9999. This is reasonably secure as well as being fairly human friendly.
It's a good idea to make sure the username is unique, that way the
password need not be.
Here's the function I use, here with words which suit a financial theme
<?php
function passgen(){
$words=array("business","entrepreneur","economy"," bank","finance","money","shares","incubate","credi t","invoice","director","efficient","workplace","o ffice",
"sales","projection");
$key=array_rand($words);
$num=rand(1,9999);
$password=$words[$key].$num;
return $password;
}

echo passgen();

?>

See http://4theweb.co.uk/test/test.php
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Sep 25 '08 #4
r0g
wozza wrote:
hi

I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.

Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?

A couple of possible complications...

1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -
http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.

2. They've also asked that the password avoids letter 'O' and numner
'0'.

Thanks in advance!

There's no standard way as it's pretty trivial to write a function to
generate random strings. This is what I use...

function rseq($x)
{
# Returns string of random alphanumeric characters of specified
length $x
# Note - mtrand (mersenne twister) used as rand not actually very
random at all!
$d = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ0123456789";
$dl = strlen($d)-1;
$s = '';
for($i = 0; $i < $x; $i++)
{
$s .= $d[(mt_rand(0,$dl))];
}
return $s;
}
Just lose the O's and 0's from $d. Do also note that this uses mt_rand
as PHP's normal random number generator is REALLY REALLY AWFUL.

Not sure what you mean when you say 'insert the rest of the exhibitor
data via a CSV upload'... What do they have and what do they want you to
do with it?

Regards,

Roger.
Sep 26 '08 #5
On 25 Sep, 14:03, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 25 Sep, 13:27, wozza <warren...@googlemail.comwrote:
hi
I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.
Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?
A couple of possible complications...
1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.
2. They've also asked that the password avoids letter 'O' and numner
'0'.
Thanks in advance!

So you want to generate random passwords without the letter 0/number 0

A simple solution would be to generate a hash of the data along with a
secret salt - say

$password=str_replace('0', 'g', substr(sha1($data . 's3cr3t'),
0,8)); // sha1 is hex encoded i.e. 0-9,a-f

Or if you want a more random solution with more emphasis on
letters....

$chars=explode(',',"a,b,c,d,e,f,g,h,i,j,k,m,n,p,q, r,t,u,x,y,z,
2,3,4,5,6,7,8,9,!,$,%,&,*,@,#"); // for niceness I've also omitted l
(L) and 1 (one)
shuffle($chars);
$password=substr($chars,0,8);

C.
Whoops - last line should be

$password=substr(implode('',$chars),0,8);

C.
Sep 26 '08 #6
On 26 Sep, 07:01, r0g <aioe....@technicalbloke.comwrote:
wozza wrote:
hi
I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.
Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?
A couple of possible complications...
1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -
http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.
2. They've also asked that the password avoids letter 'O' and numner
'0'.
Thanks in advance!

There's no standard way as it's pretty trivial to write a function to
generate random strings. This is what I use...

* function rseq($x)
* * {
* * * # Returns string of random alphanumeric characters of specified
length $x
* * * # Note - mtrand (mersenne twister) used as rand not actually very
random at all!
* * * $d = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ0123456789";
* * * $dl = strlen($d)-1;
* * * $s = '';
* * * for($i = 0; $i < $x; $i++)
* * * * {
* * * * * $s .= $d[(mt_rand(0,$dl))];
* * * * }
* * * return $s;
* * }

Just lose the O's and 0's from $d. Do also note that this uses mt_rand
as PHP's normal random number generator is REALLY REALLY AWFUL.

Not sure what you mean when you say 'insert the rest of the exhibitor
data via a CSV upload'... What do they have and what do they want you to
do with it?

Regards,

Roger.- Hide quoted text -

- Show quoted text -
Thanks for the replies guys. I've now decided to go a differetn route
in add the passwords to the records. Basically after inserting the
contents of a CSV (via that 3rd party extension for Dreamweaver I
mentioned) the browser is redirected to a php with the following
code:

<?php require_once('../Connections/connExhibiting.php'); ?>
<?php
mysql_select_db($database_connExhibiting, $connExhibiting) or
die(mysql_error());

function genRandomString() {
$length = 8;
$characters = "123456789abcdefghijklmnpqrstuvwxyz";

for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}

return $string;
}

$query = "SELECT ID, password FROM tblUsers";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
$id = $row['ID'];
$password = $row['password'];

$genPassword = genRandomString();

$sql_update = "UPDATE tblUsers SET password = '$genPassword' WHERE
(password = '' OR password is NULL)";
mysql_query($sql_update) or die(mysql_error());
}
?>
<?php
mysql_free_result($result);
?>

It _almost_ works, except the password is the same for all records - I
need the string returned by genRandomString() to be different for each
record - any help would be appreciated!

Cheers
Oct 2 '08 #7
On Sep 26, 7:01*am, r0g <aioe....@technicalbloke.comwrote:
wozza wrote:
hi
I'm a Dreamweaver user who's created a few simple data entry/
registrations forms in my time, but I'm not really a coder (though I
can follow instructions and am not afraid to dabble...) - I generally
make use of DW's builtin commands and some extensions.
Anyway I'm creating a registration site for event exhibitors and I've
been asked to come up with a method of automatically generating
passwords for inserted records, either as they're inserted or at some
point later (i.e. some kind of mass password creation). Is there a
recognised way of populating multiple records' password fields with
random passwords (say 8 characters long)?
A couple of possible complications...
1. The client wants to be able to insert the rest of the exhibitor
data via a CSV upload (I'm using a Dreamweaver extension for this -
http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
creating individual records manually via the registration site.
2. They've also asked that the password avoids letter 'O' and numner
'0'.
Thanks in advance!

There's no standard way as it's pretty trivial to write a function to
generate random strings. This is what I use...

* function rseq($x)
* * {
* * * # Returns string of random alphanumeric characters of specified
length $x
* * * # Note - mtrand (mersenne twister) used as rand not actually very
random at all!
* * * $d = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ0123456789";
* * * $dl = strlen($d)-1;
* * * $s = '';
* * * for($i = 0; $i < $x; $i++)
* * * * {
* * * * * $s .= $d[(mt_rand(0,$dl))];
* * * * }
* * * return $s;
* * }

Just lose the O's and 0's from $d. Do also note that this uses mt_rand
as PHP's normal random number generator is REALLY REALLY AWFUL.

Not sure what you mean when you say 'insert the rest of the exhibitor
data via a CSV upload'... What do they have and what do they want you to
do with it?

Regards,

Roger.- Hide quoted text -

- Show quoted text -
Thanks for the replies guys. I've now decided to go a differetn route
in add the passwords to the records. Basically after inserting the
contents of a CSV (via that 3rd party extension for Dreamweaver I
mentioned) the browser is redirected to a php with the following
code:

<?php require_once('../Connections/connExhibiting.php'); ?>
<?php
mysql_select_db($database_connExhibiting, $connExhibiting) or
die(mysql_error());
function genRandomString() {
$length = 8;
$characters = "123456789abcdefghijklmnpqrstuvwxyz";
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;

}
$query = "SELECT ID, password FROM tblUsers";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {

$genPassword = genRandomString();

$sql_update = "UPDATE tblUsers SET password = '$genPassword'
WHERE
(password = '' OR password is NULL)";
mysql_query($sql_update) or die(mysql_error());
}
?>
<?php
mysql_free_result($result);
?>
It _almost_ works, except the password is the same for all records -
I
need the string returned by genRandomString() to be different for
each
record - any help would be appreciated!
Cheers
Oct 2 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Gleep | last post by:
sorry i didn't explain it correctly before my table is like this example fields: ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..) I know that...
2
by: Dave Smithz | last post by:
Hello there, In summary: How to make my password protected php scripts available for use to public, without letting them do anything they want to DB. Previously a shared hosting hosted MySQL...
12
by: Andrew DeFaria | last post by:
I am developing a database application in which I store usernames and passwords. Naturally I want to store the passwords in an encrypted form. However, just like you see in many web applications, I...
2
by: news | last post by:
This is a tough question to ask. I need to pull up a report of all the orders in our e-commerce site, that has more than one item attributed to it. orders.ordernum, orderitems.itemnumber...
1
by: daniellee2006 | last post by:
I am creating a basic website to store people profiles and within this website i have a page that creates a table dependent on the number of records in mysql written in PHP within these tables...
0
by: thegametb | last post by:
I got this wrestling database I'm developing. It's not as straight and narrow as most sport databases are, but this has got me stumped a bit. I am trying to implement their stats in to their specific...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
6
by: Al Moodie | last post by:
Hi, I have a MySQL database where I want to updated multiple records. The table has two columns: product_number product_price I have a list with first entry product_price, second entry...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.