Created
January 31, 2017 00:35
-
-
Save CloudyWater/00fb381622d7b80df0ec95a2c67fc1a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$dsn = 'mysql:host=localhost;dbname=dbname'; | |
$username = 'username'; | |
$password = 'password'; | |
$userlogin = $_GET['username']; | |
$passwordAttempt = $_GET['password']; | |
try | |
{ | |
$dbh = new PDO($dsn, $username, $password); | |
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$statement = $dbh->prepare ("SELECT * FROM users WHERE username=:username;"); | |
$statement->bindParam (':username', $userlogin); | |
$statement->execute(); | |
$result = $statement->fetch(PDO::FETCH_ASSOC); | |
if (password_verify($passwordAttempt, $result['password'])) | |
{ | |
echo "Password Verified!"; | |
} | |
else | |
{ | |
echo "Invalid Username or Password"; | |
} | |
} | |
catch (PDOException $e) | |
{ | |
echo "Error: " . $e->getMessage () . "<br/>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment