I've used the following to generate a password:
$pwd_text = strtolower(trim( $pwd_text ));
$salt = sprintf( "%04x", time() & 0xffff);
$pwd_hash = $salt . md5( $pwd_text . $salt );
I lowercase the raw password as entered by the user, feeling that the increased ease of use outweighs the reduction in key space.
What's "salt" you ask? There's a security problem in storing hashed passwords if you just naively store the hash value: if any gains access to the file, they can mount a password attack just by changing their own password and observing its value. If it matches the target's hashed password, they now know what the target's password is, without having to any hard cryptography and without having to even once try logging in as the target. By adding a system-supplied unpredictable value, you make this attack much less likely to succeed.
Then, to test the password, having previously retrieved the user's password
hash into $stored_pwd_hash:
$salt = substr($stored_pwd_hash,0,4);
$pwd_hash = $salt . md5( strtolower($user_pwd) . $salt );
if ( $pwd_hash != $stored_pwd_hash )
{
// password not valid