Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. // Appel de la BDD
  3. include_once ("bdd.php");
  4.  
  5.  
  6. // L'utilisateur a cliqué sur le bouton submit ?
  7. if (isset($_POST) && count($_POST) > 0) {
  8.  
  9. // 1 - On récupère toutes les infos du formulaire
  10. extract(array_map("htmlspecialchars", $_POST));
  11.  
  12. // 2 : Connexion
  13. $bdd = getDataBase();
  14. $resultat = $bdd->query('SELECT MAX(numeroClient) AS max FROM clients ORDER BY numeroClient ASC');
  15. $donnees = $resultat->fetch();
  16. $newId = intval($donnees["max"]) +1;
  17.  
  18. $nbInsert = 0;
  19. try
  20. {
  21.  
  22. // Mise à jour dans la bd
  23. $query = "INSERT INTO clients(numeroClient, civil) VALUES(:pId, :pcivil)";
  24. $stmt = $bdd->prepare ($query);
  25. $stmt->bindParam(':pId', $newId);
  26. $stmt->bindParam(':pcivil', $civil);
  27.  
  28. $nbInsert = $stmt->execute();
  29. }
  30. catch(Exception $e)
  31. {
  32. $nbInsert = 0;
  33. }
  34. header("Location: liste.php");
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement