Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** INDEX.PHP ***
- $query = "SELECT * FROM `users` WHERE username = '$username'";
- $result = mysql_query($query, $con);
- $row = mysql_fetch_row($result);
- $num_rows = mysql_num_rows($result);
- $hashedpass = decryptpass($password, $row[4]);
- if(!$num_rows || $num_rows < 1 ) {
- $error = "Login Failed";
- } elseif($row[2] != $hashedpass) {
- $error = "Invalid Password";
- } else {
- // Login Successful! Set session variables
- $_SESSION['loggedIn'] = true;
- $_SESSION['username'] = $username;
- }
- *** FUNCTIONS.PHP ***
- function encryptpass($password) {
- $SALT = time();
- $SALTpass = $SALT.$SALT;
- $hash = sha1(md5($SALTpass.$password.$SALTpass));
- return $hash;
- }
- function decryptpass($password, $dbpass) {
- $SALTpass = $dbpass.$dbpass;
- $hash = sha1(md5($SALTpass.$password.$SALTpass));
- return $hash;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement