Updated SQL File to remove dummy data.
This commit is contained in:
18
add_task.php
Normal file
18
add_task.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require 'db.php';
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$name = trim($data['name'] ?? '');
|
||||
$project_id = intval($data['project_id'] ?? 0);
|
||||
|
||||
if ($name === '' || $project_id <= 0) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Invalid input']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO tasks (project_id, name) VALUES (?, ?)");
|
||||
$stmt->execute([$project_id, $name]);
|
||||
|
||||
echo json_encode(['success' => true, 'id' => $pdo->lastInsertId()]);
|
||||
?>
|
||||
Reference in New Issue
Block a user