You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
703 B
25 lines
703 B
<?php
|
|
|
|
require_once "db_connect.php";
|
|
|
|
if ($_SERVER["REQUEST_METHOD"]== "POST") {
|
|
$task_id = $_POST["task_id"] ?? null; //pokud neexistuje tak bude null
|
|
if($task_id && filter_var($task_id,FILTER_VALIDATE_INT)){
|
|
try {
|
|
$query = $pdo->prepare("DELETE FROM tasks WHERE id = :id");
|
|
$query->execute(["id" => $task_id]);
|
|
header("Location: /?status=deleted");
|
|
exit;
|
|
} catch (PDOException $e) {
|
|
//echo($e->getMessage());
|
|
header("Location: /?status=db_error");
|
|
exit;
|
|
}
|
|
} else{
|
|
header("Location: /?status=invalid_id");
|
|
exit;
|
|
}
|
|
} else {
|
|
header("Location: /");
|
|
exit;
|
|
}
|