false, 'error' => 'No active profile']); exit; } $data = json_decode(file_get_contents('php://input'), true); $name = trim($data['name'] ?? ''); if ($name === '') { http_response_code(400); echo json_encode(['success' => false, 'error' => 'Project name is required']); exit; } $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()]);