123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <html>
- <head>
- <title>Modifier une entreprise</title>
- <link href="custom.css" rel="stylesheet">
- <meta name="viewport" content="width=device-width">
- <?php
- session_start();
- if (!isset($_SESSION['loggedin'])) {
- header("Location: login.php");
- exit;
- }
- ?>
- </head>
- <body>
- <fieldset>
- <legend><font size="6">Modifier une entreprise</font></legend>
- <?php
- include('class/sqlconnect.php');
- $id = $_GET['ID'];
- $sql = "SELECT * FROM Entreprise WHERE ID = '$id'";
- $result = $conn->query($sql);
- $row = $result->fetch_assoc();
- $entreprise_id = $row['StatutEntretien'];
- ?>
- <font size="5">Société <?php echo $row['NomSociete'] ?></font>
- </fieldset><br>
- <a href="index.php">Revenir à l'accueil</a><br><br>
- <form action="modifentreprise.php" method="post">
- <table>
- <tr>
- <td>
- <input type="hidden" name="ID" value="<?php echo $id; ?>">
- <label>Nom de la société :</label>
- </td>
- <td>
- <input type="text" name="NomSociete" value="<?php echo $row['NomSociete']; ?>">
- </td>
- </tr>
- <tr>
- <td>
- <label>Adresse :</label>
- </td>
- <td>
- <input type="text" name="Adresse" value="<?php echo $row['Adresse']; ?>">
- </td>
- </tr>
- <tr>
- <td>
- <label>Numéro de téléphone (format 0102030405):</label>
- </td>
- <td>
- <input type="text" name="NumeroTel" pattern="0[0-9]{9}" value="<?php echo $row['NumeroTel']; ?>">
- </td>
- </tr>
- <tr>
- <td>
- <label>Statut :</label>
- </td>
- <td>
- <select name="statut" id="statut">
- <?php
- include('class/sqlconnect.php');
- $sql = "SELECT StatutEntretien.ID, StatutEntretien.Statut FROM StatutEntretien";
- $result = mysqli_query($conn, $sql);
- while($row = mysqli_fetch_assoc($result)){
- if ($row['ID'] == $entreprise_id) {
- echo "<option value='" . $row['ID'] . "' selected>" . $row['Statut'] . "</option>";
- } else {
- echo "<option value='" . $row['ID'] . "'>" . $row['Statut'] . "</option>";
- }
- }
- ?>
- </select>
- </table>
- <br>
- <input type="submit" name="submit" value="Enregistrer les modifications">
- </form>
- <?php
- if(isset($_POST['submit'])) {
- $id = $_POST['ID'];
- $nomsociete = $_POST['NomSociete'];
- $adresse = $_POST['Adresse'];
- $adresse = htmlentities($adresse);
- $adresse = str_replace("'", "\'", $adresse);
- $numerotel = $_POST['NumeroTel'];
- $statut = $_POST['statut'];
- $sql = "UPDATE Entreprise SET NomSociete='$nomsociete', Adresse='$adresse', NumeroTel='$numerotel', StatutEntretien='$statut' WHERE ID='$id'";
- if ($conn->query($sql) === TRUE) {
- echo "La société a été modifiée avec succès";
- header("Location: index.php");
- } else {
- echo "Erreur lors de la modification : " . $conn->error;
- }
- }
- ?>
|