Added UI and functionality for profiles
This commit is contained in:
@@ -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()]);
|
||||
|
||||
Reference in New Issue
Block a user