Skip to content

Commit

Permalink
testongv6
Browse files Browse the repository at this point in the history
  • Loading branch information
KotsiosDimis committed Dec 18, 2024
1 parent ffec77b commit 8348366
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function loginUser($username, $password) {

try {
$pdo = getDatabaseConnection();
$sql = "SELECT id, password FROM users WHERE username = :username";
$sql = "SELECT id , username password FROM users WHERE username = :username";
$stmt = $pdo->prepare($sql);
$stmt->execute([':username' => $username]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
Expand All @@ -38,6 +38,7 @@ function loginUser($username, $password) {
// Compare the entered password with the stored password
if ($password === $user['password']) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
echo json_encode(['success' => true, 'message' => 'Login successful']);
} else {
echo json_encode(['success' => false, 'message' => 'Invalid username or password']);
Expand Down Expand Up @@ -117,4 +118,5 @@ function updatePassword($userId, $newPassword) {
}
}


?>

0 comments on commit 8348366

Please sign in to comment.