pizzeria.it/edit_os.php
2024-10-30 21:14:32 +01:00

71 lines
2.2 KiB
PHP

<?php
session_start();
require 'db_con.php'; // Connexion à la base de données
// Vérifiez si l'utilisateur est connecté
if (!isset($_SESSION['user_id'])) {
header("Location: index.php");
exit;
}
// Vérifiez le rôle de l'utilisateur
$role = $_SESSION['role'];
if ($role !== 'admin' && $role !== 'chef') {
header("Location: main.php");
exit;
}
// Récupérer l'OS par ID
if (isset($_GET['id'])) {
$os_id = $_GET['id'];
$stmt = $pdo->prepare("SELECT * FROM os WHERE id = ?");
$stmt->execute([$os_id]);
$os = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$os) {
echo "Système d'exploitation non trouvé.";
exit;
}
}
// Gérer la mise à jour de l'OS
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$operating_system = $_POST['operating_system'];
$version = $_POST['version'];
$architecture = $_POST['architecture'];
$stmt = $pdo->prepare("UPDATE os SET operating_system = ?, version = ?, architecture = ? WHERE id = ?");
$stmt->execute([$operating_system, $version, $architecture, $os_id]);
header("Location: os_management.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modifier Système d'Exploitation</title>
</head>
<body>
<h1>Modifier Système d'Exploitation</h1>
<form action="edit_os.php?id=<?php echo $os['id']; ?>" method="POST">
<label for="operating_system">Système d'Exploitation :</label>
<input type="text" id="operating_system" name="operating_system" value="<?php echo htmlspecialchars($os['operating_system']); ?>" required>
<br>
<label for="version">Version :</label>
<input type="text" id="version" name="version" value="<?php echo htmlspecialchars($os['version']); ?>" required>
<br>
<label for="architecture">Architecture :</label>
<input type="text" id="architecture" name="architecture" value="<?php echo htmlspecialchars($os['architecture']); ?>" required>
<br>
<button type="submit">Mettre à jour</button>
</form>
<br>
<a href="os_management.php">Retour à la gestion des OS</a>
</body>
</html>