ajoutcontact.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <html>
  2. <head>
  3. <title>Ajouter un contact</title>
  4. </head>
  5. <body>
  6. <h1>Ajouter un contact</h1>
  7. <?php
  8. include 'class/sqlconnect.php';
  9. if(isset($_POST['submit'])){
  10. $prenom = $_POST['Prenom'];
  11. $nom = $_POST['Nom'];
  12. $poste = $_POST['Poste'];
  13. $mobile = $_POST['Mobile'];
  14. $entreprise = $_POST['IDEntreprise'];
  15. $sql = "INSERT INTO Contact (Prenom, Nom, Poste, Mobile, IDEntreprise) VALUES ('$prenom', '$nom', '$poste', '$mobile', '$entreprise')";
  16. mysqli_query($conn, $sql);
  17. }
  18. ?>
  19. <form method="post" action="">
  20. <label for="Prenom">Prénom :</label>
  21. <input type="text" name="Prenom" required>
  22. <br>
  23. <label for="Nom">Nom :</label>
  24. <input type="text" name="Nom" required>
  25. <br>
  26. <label for="Poste">Poste occupé :</label>
  27. <input type="text" name="Poste" >
  28. <br>
  29. <label for="Mobile">Numéro de mobile :</label>
  30. <input type="text" name="Mobile" >
  31. <br>
  32. <label for="Entreprise">Entreprise :</label>
  33. <select name="IDEntreprise">
  34. <?php
  35. $sql = "SELECT ID, NomSociete FROM Entreprise";
  36. $result = mysqli_query($conn, $sql);
  37. while($row = mysqli_fetch_assoc($result)){
  38. echo "<option value='" . $row['ID'] . "'>" . $row['NomSociete'] . "</option>";
  39. }
  40. ?>
  41. </select>
  42. <br><br>
  43. <input type="submit" name="submit" value="Ajouter">
  44. </form>