24 lines
657 B
PHP
24 lines
657 B
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$title = $_POST['title'] ?? '';
|
|
$description = $_POST['description'] ?? '';
|
|
|
|
if (!empty($title)) {
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("INSERT INTO tasks (title, description) VALUES (?, ?)");
|
|
$stmt->execute([$title, $description]);
|
|
} catch (PDOException $e) {
|
|
header("Location: index.php?error=" . urlencode("Database error: " . $e->getMessage()));
|
|
exit;
|
|
}
|
|
}
|
|
header("Location: index.php?success=1");
|
|
exit;
|
|
} else {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|