-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
23 lines (23 loc) · 726 Bytes
/
add.php
File metadata and controls
23 lines (23 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
require_once __DIR__.'/includes/csrf.php';
require_once __DIR__.'/includes/db.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
exit;
}
if (!csrf_validate($_POST['csrf_token'] ?? '')) {
die('Invalid CSRF token');
}
$title = trim($_POST['title'] ?? '');
desc = trim($_POST['description'] ?? '');
$priority = (int)($_POST['priority'] ?? 2);
if ($title === '' || $desc === '') {
$_SESSION['error'] = 'عنوان و توضیحات لازم است.';
header('Location: index.php');
exit;
}
$stmt = $conn->prepare('INSERT INTO tasks (title, description, priority, completed, created_at) VALUES (?, ?, ?, 0, NOW())');
$stmt->execute([$title, $desc, $priority]);
header('Location: index.php');
exit;
?>