Basically, you have two options, varying in complexity:
- Store a Hash of the registered user's password, using a hashing algorithm of your choice (more into this later).
- create a random salt (a constant, secret string) to be used together with the user's password, to create the hash as stated above and then store that hash in the DB.
When you retrieve the user record, you compare the hash computed from the provided password, with the hash stored in the DB.
Example:
$HashedPass = hash('sha512', $password);
or with a pre-defined SALT:
$HashedPass = hash('sha512', $password.SALT_STRING);
Store this into the DB as you did before.
Authenticating in done similarly:
$HashedPass = hash('sha512', $password.SALT_STRING);
and then retrieve from the DB based on that hash comparison to the stored one.
Now, I'd like to address your concerns about Hashing algorithms:
You dont have to use md5, you can as well use more secure hashing algorithms, refer to a comment here:
PHP's hash function
One suggestion is to use sha512 algorithm.
Most importantly, you should understand that hash is a one way conversion - there is no practical way to reverse engineer the original password from the hash alone, only perhaps finding alternative strings, which produce the same hash string.
I hope you find using a strong Hash algorithm, along with a Salt to mitigate the damage of a stolen Hash DB, good enough for your needs.