-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_status.php
More file actions
28 lines (23 loc) · 822 Bytes
/
update_status.php
File metadata and controls
28 lines (23 loc) · 822 Bytes
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
26
27
28
<?php
session_start();
include('db.php');
// Check if user is admin
if (!isset($_SESSION['user_id']) || !isset($_SESSION['is_admin']) || $_SESSION['is_admin'] != 1) {
header('Location: login.php');
exit();
}
if (isset($_POST['ticket_id']) && isset($_POST['status'])) {
$db = getDbConnection();
// Validate status
$validStatuses = ['open', 'in_progress', 'pending', 'resolved', 'closed'];
if (!in_array($_POST['status'], $validStatuses)) {
header('Location: admin.php');
exit();
}
$stmt = $db->prepare('UPDATE tickets SET status = ?, updated_at = DATETIME("now") WHERE id = ?');
$stmt->bindValue(1, $_POST['status'], SQLITE3_TEXT);
$stmt->bindValue(2, $_POST['ticket_id'], SQLITE3_INTEGER);
$stmt->execute();
}
header('Location: admin.php');
exit();