Reputation: 499
Part of the code I'm using is:
$password = MD5($password);
$account_created = date("Y-m-d H-i-s");
db_insert("users","user_id,username,password,account_created,registration_ip","ENCRYPT('$_POST[username] $account_created'),'$_POST[username]',MD5('$_POST[password]'),'$account_created','$_SERVER[REMOTE_ADDR]'");
$user = db_get_array("users","username='$_POST[username]'");
db_insert("usersettings","user_id,timezone","'$user[user_id]','$_POST[timezone]'");
db_update("users","login_id = ENCRYPT('$user[username] $password')","user_id='$user[user_id]'");
The script continues before and after that
Anyway, the problem I'm having is that, there are two calls to ENCRYPT() in the MySQL queries, but for some reason both of them have the same values
The user ID and login ID are meant to be different, whats the problem?
Upvotes: 1
Views: 225
Reputation: 25191
ENCRYPT() ignores all but the first eight characters of str, at least on some systems. This behavior is determined by the implementation of the underlying crypt() system call.
http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html#function_encrypt
So if your username is longer than 8 characters...
Upvotes: 3