I have stored user passwords in an encrypted format in my database. However, now when user wants to login and tries to put their original password the code always compares the entered (original) password with the encrypted version stored in the database, leading to a failed login.
Please tell me how to compare the entered (original) password with the encrypted password stored in the database.
You should almost certainly be hashing the password rather than using reversible encryption. You may need to do this with a salt too… in which case the correct steps are:
Note the difference between the when you store the hashed password to start with, when you generate a random salt, and when you verify the stored hash, when you use the stored salt.