-1

Here is my code:

$param = $old_password.$salt;
$hashed_password = $this->general->hash($param);
//echo $hashed_password;echo " "; echo $userdata->password;exit;
if($hashed_password == $userdata->password){
    print_r("com");exit;
}
print_r("didn't match");exit;

when I echo as above result is

8fb9ccf75da3c0eb285d3dddd80895a8f15f64d5 8fb9ccf75da3c0eb285d3dddd80895a8f15f64d5

which is exactly same. But it doesn't enters into the if statement.

Naim Malek
  • 1,186
  • 1
  • 11
  • 21
Tekraj Shrestha
  • 1,228
  • 3
  • 20
  • 48

3 Answers3

0

Try var_dump() on both variables. Maybe you have empty spaces somewhere.

jmd_dk
  • 12,125
  • 9
  • 63
  • 94
Sergiu Vintu
  • 47
  • 1
  • 5
0

Compare string using strcmp() function

$param = $old_password.$salt;
$hashed_password = $this->general->hash($param);
if (strcmp($hashed_password, $userdata->password) == 0) {
    echo "matched"; exit;
}else{
    echo "didn't match"; exit;
}

Refrence : http://php.net/manual/en/function.strcmp.php

Naim Malek
  • 1,186
  • 1
  • 11
  • 21
-1

Try This

         // $param=$old_password.$salt;
         $hashed_password = $this->general->hash($param);
         $password = $userdata->password;
         //echo $hashed_password;echo " "; echo $userdata->password;exit;
         if($hashed_password == $password)
         {
          print_r("com");exit;
         }else
         {
            print_r("didn't match");exit;   
         }