如何比较md5密码php

I need to check if $user_entered_passidential to $hash_val . Please help me?

    <?php
    $mypass = "Rainbow";
    $hash_val = md5($mypass);

    echo $hash_val; //always 32 characters

    $user_entered_pass = "rainbow";
?>

You can hash $user_entered_pass and compare, I use this method.

<?php
    $mypass = "Rainbow";
    $hash_val = md5($mypass);

    echo $hash_val; //always 32 characters

    $user_entered_pass = "rainbow";

    if(md5($user_entered_pass) == $hash_val){
      //The passwords are equal
    }
?>

Convert user entered password to md5 and then check. $user_entered_pass_has = md5($user_entered_pass) Then check for equality.

Compare it with the identical operator ===, e.g.:

if ($hashFromDatabase === md5($userEnteredPasswort)) {
    // authenticated ...
}

However, I strongly recommend you not to use md5 as hashing algorithm. Check out this answer here: Secure hash and salt for PHP passwords

Moreover, I recommend you using the new password hashing API from PHP (password_hash() and password_verify()).