How can a "Forgot Password" function be implemented in PHP when passwords are stored as MD5 hashes in a database?

When passwords are stored as MD5 hashes in a database, the original passwords cannot be retrieved as MD5 is a one-way hashing algorithm. To implement a "Forgot Password" function, a common approach is to generate a unique token, store it in the database along with the user's email, and send a password reset link to the user's email. When the user clicks on the link, they can enter a new password which will be hashed and stored in the database.

```php
// Generate a unique token
$token = md5(uniqid(rand(), true));

// Store the token in the database along with the user's email
$query = "UPDATE users SET reset_token = '$token' WHERE email = '$user_email'";
// Execute the query

// Send the password reset link to the user's email
$reset_link = "http://example.com/reset_password.php?token=$token";
// Send email with $reset_link to $user_email
```
This code snippet demonstrates how to generate a unique token, store it in the database, and send a password reset link to the user's email for implementing a "Forgot Password" function when passwords are stored as MD5 hashes.