My requirement is to encrypt a password and update the MySQL database in one go.
This is how I tried to do this. But was not successful.
Is this a good approach?
php:
require_once("conn.php"); //PDO
//I've set all passwords in an array
$values = array (
array ( "studentID" => "SCI164" , "pass" => "ABCD12"),
array ( "studentID" => "GEO24" , "pass" => "XYZ1"),
array ( "studentID" => "SCI112" , "pass" => "PQR89")
)
foreach ($values as $temp) {
foreach($temp as $key => $val){
$stuID = $key"studentID";
$rawPass = $key"pass";
$encPass = md5($rawPass);
$sql_update = "UPDATE students_db
set pass = $encPass
where studentID = $stuID Limit 1";
}
}
password hashingor if < 5.5 use the backward compatibility instead