i have a table that holds my users information like username , password , name , family , etc. already when a user register in my site her password hashes with one md5() function then insert into table. my table have about 50000 records now.
but now i want to hash their passwords with two md5() function again for security issues. for that i write below code that first selects all of the users and then execute a update Query for change passwords:
$allMembers = mysql_query("select `username`,`password` from `members`",$conn);
if (mysql_num_rows($allMembers) > 0){
while($row = mysql_fetch_array($allMembers)){
$oldPass = $row['password'];
$newPass = md5(md5('Hello'.$oldPass.'Friends'));
mysql_query("update `members` set `password`='$newPass' where `username`='".$row['username']."'",$conn);
}
}
echo("Yes");
but when i run this code It took very little and produce No Data Received message.
but now how i update the password field in my large table ?
Edit :i was used salt + md5 but removed it in my code for Summarization 🙂
Just run it as a single query:
BTW double MD5 is useless. you can MD5 + salt or SHA1 + salt if you want better security.