A website which is dealing with user registrations should always store user passwords as MD5 hash for security reasons. An easy tutorial for storing and retrieving MD5 hash in a MySQL database as follows.
Flowchart for storing a password:
While storing password into database first convert user’s entered password using md5 function then store into database.
PHP code encrypting to MD5:
//SQL query to store $encryptedpass into database
Flowchart for decoding MD5 password:
While retrieving password from database first take password from user(plain text), convert it to md5 hash and compare with stored value in database.
PHP code decrypting from MD5:
//SQL query to compare $encryptedpass with stored database
MD5 hash cannot be decoded directly. There is no such formula/function. Only comparing is possible.