Hi.
I've searched the forum and found a similar thread back from 2002. WOW! BUT, noone answered, so I want to know exactly the same thing as he. I know I must use a for loop for that but my scripting skills aren't so good.
This is what I thought would work but what it does is to generate different passes each time but twice (if we have 3 columns it will generate 6 passes if we have 9, then 18 passes, & so on...) Random password function was taken from phpfreaks tutorial:
function RandomPassword()
{
$use = "abcdefghjkmnopqrstuvwxyz0123456789";
srand((double)microtime() * 1000000);
$i = 0;
while($i <= 9)
{
$num = rand() % 33;
$tmp = substr($use, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
//connect database
$dbconn = mysql_connect("localhost", "root", "");
//select database name
$dbname = mysql_select_db("test", $dbconn);
$sql1 = "SELECT * FROM users";
$query = mysql_query($sql1);
$num_rows = mysql_num_rows($query);
while($row = mysql_fetch_array($query))
for($i=0; $i<$num_rows; $i++)
{
$random_pass = RandomPassword();
echo 'Your password is: <b>'.$random_pass.'</b>';
$sql2 = "UPDATE users SET password = '{$random_pass}'";
$query2 = mysql_query($sql2);
$i++;
}
Now the password that change all the password columns in the database is the last generated password and not like this which would be the correct thing: 1st pass goes at first column, 2nd pass at second column. It just fills all columns with the last pass.