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