-
-
Save anonymous/ff26b01a4e9cb9573b95 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
function check_username_and_pw($u, $pw) { | |
$link = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.'); | |
$query = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1"; | |
if($stmt = $link->prepare($query)) { | |
$p = md5($pw); | |
$stmt->bind_param('ss', $u, $p); | |
$stmt->execute(); | |
$stmt->bind_result($id, $username, $pw); | |
if($stmt->fetch()) { | |
$_SESSION['authorized'] = true; | |
$_SESSION['username'] = $username; | |
return true; | |
} else { | |
return false; | |
} | |
$stmt->close(); | |
} | |
$link->close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment