The way you are trying to implement this is wrong at first place. Never ever store password either in plain text or in encrypted format.
The correct way is to store hash of the password. That is,try using one way cryptographic hash function like SHA256 to generate hash from password,store it in database. You should also use salt.See this link :
Beginners guide to a secure way of storing passwords[
^]
Whenever user tries to login,generate hash from the entered password using the same algorithm and compare it with stored one. So now,your are comparing
hash to hash,not password to password.