Added UI and functionality for profiles

This commit is contained in:
2026-02-12 14:17:24 -08:00
parent f879d25bc7
commit 8fc8d737e5
7 changed files with 282 additions and 139 deletions

View File

@@ -6,6 +6,13 @@ header('Content-Type: application/json');
require_login();
$user_id = current_user_id();
$profile_id = $_SESSION['active_profile_id'] ?? null;
if (!$profile_id) {
http_response_code(400);
echo json_encode(['success' => false, 'error' => 'No active profile']);
exit;
}
$data = json_decode(file_get_contents('php://input'), true);
$name = trim($data['name'] ?? '');
@@ -16,7 +23,7 @@ if ($name === '') {
exit;
}
$stmt = $pdo->prepare("INSERT INTO projects (user_id, name) VALUES (?, ?)");
$stmt->execute([$user_id, $name]);
$stmt = $pdo->prepare("INSERT INTO projects (user_id, profile_id, name) VALUES (?, ?, ?)");
$stmt->execute([$user_id, $profile_id, $name]);
echo json_encode(['success' => true, 'id' => $pdo->lastInsertId()]);