diff --git a/login.php b/login.php index 5d831d0..fb9024c 100644 --- a/login.php +++ b/login.php @@ -2,9 +2,6 @@ session_start(); $db = new SQLite3('ask.db'); -//$version = $db->querySingle('SELECT SQLITE_VERSION()'); - - $users_table = $db->query("CREATE TABLE IF NOT EXISTS users( id INTEGER PRIMARY KEY, username TEXT, @@ -17,6 +14,18 @@ $logErrorMsg = ""; $validUser = false; if(isset($_SESSION["login"])) $validUser = $_SESSION["login"] === true; if(isset($_POST["log"])){ + if($_POST["logname"]){ + $user = $_POST["logname"]; + $shadow = $db->querySingle("SELECT shadow FROM users WHERE username = '$user'"); + if(password_verify($_POST["password"],$shadow)){ + echo("Logged in"); + } + else{ + $logErrorMsg = "Incorrect user or password"; + } + } + else $logErrorMsg = "Please input a username"; + $validUser = $_POST["logname"] == "admin" && password_verify($_POST["password"], $hash); if(!$validUser) $errorMsg = "Invalid username or password."; else $_SESSION["login"] = true;