37497-vm/edit_division.php
Flatlogic Bot 65bff23a0b 1
2026-01-16 09:31:10 +00:00

40 lines
995 B
PHP

<?php
require_once 'db/config.php';
$id = $_GET['id'];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
try {
$stmt = db()->prepare("UPDATE divisions SET name = ? WHERE id = ?");
$stmt->execute([$name, $id]);
header('Location: user_management.php');
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
try {
$stmt = db()->prepare("SELECT * FROM divisions WHERE id = ?");
$stmt->execute([$id]);
$division = $stmt->fetch();
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Division</title>
</head>
<body>
<h2>Edit Division</h2>
<form method="post">
<label>Division Name:</label>
<input type="text" name="name" value="<?= htmlspecialchars($division['name']) ?>" required>
<button type="submit">Update</button>
</form>
<a href="user_management.php">Back to User Management</a>
</body>
</html>