prepare('SELECT id, username, password_hash FROM users WHERE username = ?'); $stmt->execute([$username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; header('Location: index.php'); exit; } else { $error = 'Invalid username or password.'; } } catch (PDOException $e) { $error = 'Database error: ' . $e->getMessage(); } } } ?> Login

Login

Don't have an account? Sign Up