ajoutcontact.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html>
  2. <head>
  3. <title>Ajouter un contact</title>
  4. <link href="custom.css" rel="stylesheet">
  5. <meta name="viewport" content="width=device-width">
  6. </head>
  7. <body>
  8. <h1>Ajouter un contact</h1>
  9. <?php
  10. include 'class/sqlconnect.php';
  11. if(isset($_POST['submit'])){
  12. $prenom = $_POST['Prenom'];
  13. $nom = $_POST['Nom'];
  14. $poste = $_POST['Poste'];
  15. $mobile = $_POST['Mobile'];
  16. $entreprise = $_POST['IDEntreprise'];
  17. $sql = "INSERT INTO Contact (Prenom, Nom, Poste, Mobile, IDEntreprise) VALUES ('$prenom', '$nom', '$poste', '$mobile', '$entreprise')";
  18. mysqli_query($conn, $sql);
  19. }
  20. ?>
  21. <a href="index.php">Revenir à l'accueil</a><br><br>
  22. <form method="post" action="">
  23. <table>
  24. <tr>
  25. <td>
  26. <label for="Prenom">Prénom :</label>
  27. </td>
  28. <td>
  29. <input type="text" name="Prenom" required>
  30. </td>
  31. </tr>
  32. <tr>
  33. <td>
  34. <label for="Nom">Nom :</label>
  35. </td>
  36. <td>
  37. <input type="text" name="Nom" required>
  38. </td>
  39. </tr>
  40. <tr>
  41. <td>
  42. <label for="Poste">Poste occupé :</label>
  43. </td>
  44. <td>
  45. <input type="text" name="Poste" >
  46. </td>
  47. </tr>
  48. <tr>
  49. <td>
  50. <label for="Mobile">Numéro de mobile :</label>
  51. </td>
  52. <td>
  53. <input type="text" name="Mobile" >
  54. </td>
  55. </tr>
  56. <tr>
  57. <td>
  58. <label for="Entreprise">Entreprise :</label>
  59. </td>
  60. <td>
  61. <select name="IDEntreprise">
  62. <?php
  63. $sql = "SELECT ID, NomSociete FROM Entreprise";
  64. $result = mysqli_query($conn, $sql);
  65. while($row = mysqli_fetch_assoc($result)){
  66. echo "<option value='" . $row['ID'] . "'>" . $row['NomSociete'] . "</option>";
  67. }
  68. ?>
  69. </select>
  70. </td>
  71. </tr>
  72. </table>
  73. <br>
  74. <input type="submit" name="submit" value="Ajouter">
  75. </form>