// user has submit the registration form
$password = $_POST['password']; // user's plaintext password as submitted by the form
// In this example, we will assume the user entered
// as his password.
// Now we make an MD5 hash of this.
$md5_hash = md5($password);
// $md5_hash currently looks like this:
// More code here would insert this hash into a database
// The original, plaintext password that the user entered is discarded!
// user has submit the login form
// Here is the plaintext password which the user has entered
$password = $_POST['password'];
// Some code here will select the MD5 hash from the database
$hash_from_database = '742898c83a580b611249ecc2f6cc7a2d';
// Now what we do here is md5() the password which the user just submitted
// and see if it equals $hash_from_database
$hash_from_user = md5($password);
// Now compare!
if ($hash_from_user == $hash_from_database)
echo('You have entered the password correctly! The MD5 hashes matched!');
echo('You have entered a password other than greendog32.
Since the hashes did not match, the password you entered was wrong!');