Created
January 29, 2010 04:42
-
-
Save emerose/289455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$salt = substr(md5(rand()), 0, 4); | |
$hashedpassword = md5($password.$salt); | |
$sql = "INSERT INTO Users (Username, Password, Salt) " . | |
"VALUES ('" . addslashes($username) . "', " . | |
"'$hashedpassword', '$salt')"; | |
$db->executeQuery($sql); | |
// ... | |
$sql = "SELECT Salt FROM Users WHERE Username = '" . | |
addslashes($username) . "'"; | |
$rs = $db->executeQuery($sql); | |
$salt = $rs->getValueByNr(0,0); | |
$hashedpassword = md5($password.$salt); | |
$sql = "SELECT * FROM Users WHERE " . | |
"Username = '" . addslashes($username) . "' AND " . | |
"Password = '$hashedpassword'"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment