30 lines
737 B
PHP
30 lines
737 B
PHP
<?php
|
|
require_once 'includes/header.php';
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || !$_SESSION['is_admin']) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$request_id = $_POST['request_id'];
|
|
$status = $_POST['status'];
|
|
|
|
try {
|
|
$pdo = db();
|
|
$sql = "UPDATE service_requests SET status = ? WHERE id = ?";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([$status, $request_id]);
|
|
|
|
header('Location: service_request_details.php?id=' . $request_id);
|
|
exit;
|
|
|
|
} catch (PDOException $e) {
|
|
die("Database error: " . $e->getMessage());
|
|
}
|
|
} else {
|
|
header('Location: service_requests.php');
|
|
exit;
|
|
}
|
|
?>
|