Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 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. var_dump($civil);
  18.  
  19. $nbInsert = 0;
  20. try
  21. {
  22.  
  23. // Mise à jour dans la bd
  24. $query = "INSERT INTO clients(numeroClient, civil) VALUES(:pId, :pcivil)";
  25. $stmt = $bdd->prepare ($query);
  26. $stmt->bindParam(':pId', $newId);
  27. $stmt->bindParam(':pcivil', $civil);
  28.  
  29. $nbInsert = $stmt->execute();
  30. echo "yo";
  31. }
  32. catch(Exception $e)
  33. {
  34. $nbInsert = 0;
  35. }
  36. header("Location: liste.php?req=".$nbInsert);
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement