UPDATE:
This link is quite helpful in understanding use cases for hash algorithms & encryption algorithms. Fundamental difference between Hashing and Encryption algorithms
"Use a hash function when you want to compare a value but can't store the plain representation (for any number of reasons). Passwords should fit this use-case very well since you don't want to store them plain-text for security reasons (and shouldn't)"
"Use encryption whenever you need to get the input data back out. Notice the word need. If you're storing credit card numbers, you need to get them back out at some point, but don't want to store them plain text. So instead, store the encrypted version and keep the key as safe as possible."
As the comments mention, md5 and sha1 type hashes are no longer secure. Use php's built-in password hashing functions. You can read up about them here http://php.net/manual/en/book.password.php
particularly password_hash() & password_verify()
An example usage for password_verify:
// grab hashed pass from db - to compare against - then perform password_verify() method
if (password_verify($inputPassword, $dbPass)) {
// success
}
where $inputPassword
is the plain text password entered into the login form.
and an example usage of password_hash()
$hash = password_hash($inputPassword, PASSWORD_BCRYPT);