modificationstatut.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Modification statut entretien</title>
  5. </head>
  6. <?php
  7. include("class/sqlconnect.php");
  8. ?>
  9. <body>
  10. <form action="modificationstatut.php" method="post">
  11. <label for="entreprise">Entreprise</label>
  12. <select name="entreprise" id="entreprise">
  13. <?php
  14. $sql = "SELECT ID, NomSociete FROM Entreprise";
  15. $result = mysqli_query($conn, $sql);
  16. while($row = mysqli_fetch_assoc($result)){
  17. echo "<option value='" . $row['ID'] . "'>" . $row['NomSociete'] . "</option>";
  18. }
  19. ?>
  20. </select>
  21. <br>
  22. <label for="statut">Statut d'entretien</label>
  23. <select name="statut" id="statut">
  24. <?php
  25. $sql = "SELECT ID, Statut FROM StatutEntretien";
  26. $result = mysqli_query($conn, $sql);
  27. while($row = mysqli_fetch_assoc($result)){
  28. echo "<option value='" . $row['ID'] . "'>" . $row['Statut'] . "</option>";
  29. }
  30. ?>
  31. </select>
  32. <br>
  33. <input type="submit" name="submit" value="Modifier statut">
  34. </form>
  35. <?php
  36. if(isset($_POST['submit'])){
  37. $entreprise = $_POST['entreprise'];
  38. $statut = $_POST['statut'];
  39. $sql = "UPDATE Entreprise SET StatutEntretien = '$statut' WHERE ID = '$entreprise'";
  40. $result = mysqli_query($conn, $sql);
  41. if($result){
  42. echo "Statut d'entretien mis à jour avec succès.";
  43. } else {
  44. echo "Erreur lors de la mise à jour du statut d'entretien : " . mysqli_error($conn);
  45. }
  46. }
  47. ?>
  48. </body>
  49. </html>