The missing quote was because I took out some stuff to try to make the line shorter. What I do is something like this:
$crypted_password = md5($_POST['password']);
$sql="UPDATE users SET password='$crypted_password'";
$result = mysql_query($sql,$dblink);
...write this to the database.
Then to compare I have:
$password-IN = $_POST['password'];
$c_password = md5($password-IN);
$num = 0;
$sql = "SELECT * FROM users where username='$_POST['username'] ";
$sql .= "AND password = '$c_password'";
$result = mysql_query($sql,$dblink);
while ($row = mysql_fetch_array($result)) {
$num++;
}
$num is returning 0, so I take out the AND password=$c_password. It find the user, then I echo the crypted password I was trying to match on and what's in the db and they are different.
Am I missing something? All I did was change crypt($password,$salt) to md5($password). It was working with crypt, but is not working with md5. What I can't figure out is why this happens, I echo username, password, and crypted password, just before I write to the db and get one thing for crypted password, then (in a different script) echo the same information and get a different crypted password, even though the password before encryption is the same both times.
I'm about ready to change it back though I think I'm going to try crypt($password,$username) instead of using a preset $salt for everyone. Doing it that way is at least as secure as md5. My usernames are anywhere from 5 to 10 characters long.