Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Données Mesurées</title>
  4. <link rel="stylesheet" href="styleres.css" />
  5. <link rel="shortcut icon" href="Terminator.ico" type="image/x-icon"/>
  6. <link rel="icon" href="Terminator.ico" type="image/x-icon"/>
  7. </head>
  8. <body>
  9. <header>
  10. <p class="Titre">
  11. Projet 2015-2016 : Bras Manipulateur 6 axes
  12. </p>
  13. </header>
  14. <footer>
  15. <p class="co">Copyright ® Enetue. Tout droits reserves</p>
  16. </footer>
  17. <img src="Si.png" class="Logo" alt="Logo du Site"/>
  18. <a href="index.html" class="home"></a>
  19. <form action="DM.php" method="post">
  20. <textarea rows="3" cols="80" name="don" class="don" placeholder="Donnée Mesurée..."required></textarea>
  21. <input type="submit" value="Valider" class="val2"/>
  22. <input type="text" name="ind" class="ind" placeholder="Index" required/>
  23. <input type="password" class="mdp2" placeholder="Mot De Passe" name="mdp" required />
  24. </form>
  25.  
  26. <?php
  27. $nom_du_serveur = "mysql:host=mysql.hostinger.fr;dbname=u537521533_test";
  28. $nom_utilisateur = "u537521533_test1";
  29. $mot_de_passe = "xxxxxxxxx";
  30.  
  31. $options = array(
  32. PDO::ATTR_CASE => PDO::CASE_LOWER,
  33. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  34. PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
  35. );
  36. try {
  37. $link = new PDO($nom_du_serveur, $nom_utilisateur, $mot_de_passe, $options);
  38. }
  39. catch (Exception $e)
  40. {
  41. echo "Connection à MySql impossible : ", $e->getMessage();
  42. die();
  43. }
  44. $ind=$_POST['ind'];
  45. $do=$_POST['do'];
  46. echo utf8_encode($do);
  47. if (isset($_POST['do']))
  48. {
  49. if(isset($_POST['mdp']) && $_POST['mdp'] == "xxxxxxxxx")
  50. {
  51. /*-----------------------------------*/
  52. /* Insertion dans la table "clients" */
  53. /*-----------------------------------*/
  54. $requetea = $link->prepare("SELECT * FROM dm WHERE id=:param1");
  55. $requetea->bindParam('param1',$ind);
  56. $requetea->execute();
  57. try {
  58. if(count($requetea->fetchAll()) !=0)
  59. {
  60. $requete3a = $link->prepare("UPDATE dm SET dom=:do WHERE id= :param1");
  61. $requete3a->execute(array(
  62. 'do' => $do,
  63. 'param1' => $ind
  64. ));
  65. }
  66. else
  67. {
  68. $insa = $link->prepare("INSERT INTO `dm` (`ind`, `dom`) VALUES (:param1, :param2)");
  69. $insa->bindParam('param1',$ind);
  70. $insa->bindParam('param2',$dom);
  71. $insa->execute();
  72. }
  73. }
  74. catch ( Exception $e ) {
  75. echo "Une erreur est survenue dans la requète insert : ", $e->getMessage();
  76. die();
  77. }
  78. }
  79. else {
  80. echo '<script>
  81. alert("Mot de passe incorrect !");
  82. </script>';
  83. }
  84.  
  85. }
  86.  
  87. ?>
  88. <table class="tabresu">
  89. <tr>
  90. <th>Index</th>
  91. <th>Données Mesurées</th>
  92. </tr>
  93.  
  94. <?php
  95. /*------------------------------*/
  96. /* Vidage de la table 'clients' */
  97. /*------------------------------*/
  98.  
  99. $requete2a = "SELECT * FROM dm ORDER BY id ASC";
  100.  
  101. try {
  102. $sql2a = $link->query($requete2a);
  103.  
  104. foreach ($sql2a->fetchAll(PDO::FETCH_OBJ) as $key => $enreg)
  105. {
  106. echo "<tr style=\"".($key%2 ? 'background:#808080;' : '')."\"><td>$enreg->ind</td>";
  107. echo "<td>$enreg->dom</td>";
  108. }
  109.  
  110. $sql2a->closeCursor();
  111. }
  112. catch ( Exception $e )
  113. {
  114. echo "Une erreur est survenue dans la requète select 2 : ", $e->getMessage();
  115. die();
  116. }
  117.  
  118. $link = null;
  119. ?>
  120. </table>
  121.  
  122. <?php
  123.  
  124. /*------------------*/
  125. /* Message d'erreur */
  126. /*------------------*/
  127.  
  128. if ($reponse != "")
  129. echo "<div id=\"reponse\">$reponse</div>";
  130. ?>
  131.  
  132. </body>
  133. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement