Don't store the password directly; this would enable anyone
who managed to get even read-only access to the database
to discover everyone's password. Instead, use mcrypt()
and store the hash. You then use mcrypt() on the incoming
password and compare that to the stored hash. Don't
forget to add a "salt" value to make a known-plaintext attack
a little harder to achieve. I.e. creating the hash to save to
the database:
$salt = sprintf( "%04x", time() & 0xffff);
$pw_hash = $salt . md5( $pw_plaintext) . $salt );
Then, to test ($pw_retrieved is the stored value from the database):
$salt = substr($pw_retrieved,0,4);
$pwvalue = $salt . md5( strtolower($pw_entered) . $salt );
if ($pwvalue == $pw_retrieved)
...