-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_task.php
More file actions
25 lines (25 loc) · 1.11 KB
/
add_task.php
File metadata and controls
25 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
$selected_lang = $_GET['lang'] ?? $_SESSION['lang'] ?? 'en';
header("Location: authenticate.php?lang=" . urlencode($selected_lang));
exit;
}
require "config.php";
$available_langs = ['en' => 'English', 'ru' => 'Русский', 'es' => 'Español', 'de' => 'Deutsch', 'pt' => 'Português', 'tr' => 'Türkçe', 'zh-CN' => '中文', 'uz' => 'Oʻzbekcha', 'fa' => 'فارسی', 'ar' => 'العربية'];
$selected_lang = $_GET['lang'] ?? $_SESSION['lang'] ?? 'en';
if (!array_key_exists($selected_lang, $available_langs)) {
$selected_lang = 'en';
}
$_SESSION['lang'] = $selected_lang;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = trim($_POST['title'] ?? '');
$description = trim($_POST['description'] ?? '');
if (!empty($title)) {
$stmt = $pdo->prepare("INSERT INTO tasks (title, description, status) VALUES (:title, :description, 'pending')");
$stmt->execute(['title' => $title, 'description' => $description ?: null]);
}
}
header("Location: index.php?lang=" . urlencode($selected_lang));
exit;
?>