How can a password query be performed when passwords are encrypted with MD5 in MySQL?
To perform a password query when passwords are encrypted with MD5 in MySQL, you can use the MD5 function in MySQL to encrypt the input password before comparing it with the stored encrypted password. This way, you can ensure that the passwords match even though they are stored in encrypted form.
<?php
// Assuming $inputPassword is the password entered by the user
$inputPassword = "password123";
// Encrypt the input password using MD5
$encryptedInputPassword = md5($inputPassword);
// Perform a query to check if the encrypted input password matches the stored encrypted password
$query = "SELECT * FROM users WHERE username = 'example' AND password = '$encryptedInputPassword'";
// Execute the query and check the result
?>