Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Données Mesurées</title>
- <link rel="stylesheet" href="styleres.css" />
- <link rel="shortcut icon" href="Terminator.ico" type="image/x-icon"/>
- <link rel="icon" href="Terminator.ico" type="image/x-icon"/>
- </head>
- <body>
- <header>
- <p class="Titre">
- Projet 2015-2016 : Bras Manipulateur 6 axes
- </p>
- </header>
- <footer>
- <p class="co">Copyright ® Enetue. Tout droits reserves</p>
- </footer>
- <img src="Si.png" class="Logo" alt="Logo du Site"/>
- <a href="index.html" class="home"></a>
- <form action="DM.php" method="post">
- <textarea rows="3" cols="80" name="don" class="don" placeholder="Donnée Mesurée..."required></textarea>
- <input type="submit" value="Valider" class="val2"/>
- <input type="text" name="ind" class="ind" placeholder="Index" required/>
- <input type="password" class="mdp2" placeholder="Mot De Passe" name="mdp" required />
- </form>
- <?php
- $nom_du_serveur = "mysql:host=mysql.hostinger.fr;dbname=u537521533_test";
- $nom_utilisateur = "u537521533_test1";
- $mot_de_passe = "xxxxxxxxx";
- $options = array(
- PDO::ATTR_CASE => PDO::CASE_LOWER,
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
- );
- try {
- $link = new PDO($nom_du_serveur, $nom_utilisateur, $mot_de_passe, $options);
- }
- catch (Exception $e)
- {
- echo "Connection à MySql impossible : ", $e->getMessage();
- die();
- }
- $ind=$_POST['ind'];
- $do=$_POST['do'];
- echo utf8_encode($do);
- if (isset($_POST['do']))
- {
- if(isset($_POST['mdp']) && $_POST['mdp'] == "xxxxxxxxx")
- {
- /*-----------------------------------*/
- /* Insertion dans la table "clients" */
- /*-----------------------------------*/
- $requetea = $link->prepare("SELECT * FROM dm WHERE id=:param1");
- $requetea->bindParam('param1',$ind);
- $requetea->execute();
- try {
- if(count($requetea->fetchAll()) !=0)
- {
- $requete3a = $link->prepare("UPDATE dm SET dom=:do WHERE id= :param1");
- $requete3a->execute(array(
- 'do' => $do,
- 'param1' => $ind
- ));
- }
- else
- {
- $insa = $link->prepare("INSERT INTO `dm` (`ind`, `dom`) VALUES (:param1, :param2)");
- $insa->bindParam('param1',$ind);
- $insa->bindParam('param2',$dom);
- $insa->execute();
- }
- }
- catch ( Exception $e ) {
- echo "Une erreur est survenue dans la requète insert : ", $e->getMessage();
- die();
- }
- }
- else {
- echo '<script>
- alert("Mot de passe incorrect !");
- </script>';
- }
- }
- ?>
- <table class="tabresu">
- <tr>
- <th>Index</th>
- <th>Données Mesurées</th>
- </tr>
- <?php
- /*------------------------------*/
- /* Vidage de la table 'clients' */
- /*------------------------------*/
- $requete2a = "SELECT * FROM dm ORDER BY id ASC";
- try {
- $sql2a = $link->query($requete2a);
- foreach ($sql2a->fetchAll(PDO::FETCH_OBJ) as $key => $enreg)
- {
- echo "<tr style=\"".($key%2 ? 'background:#808080;' : '')."\"><td>$enreg->ind</td>";
- echo "<td>$enreg->dom</td>";
- }
- $sql2a->closeCursor();
- }
- catch ( Exception $e )
- {
- echo "Une erreur est survenue dans la requète select 2 : ", $e->getMessage();
- die();
- }
- $link = null;
- ?>
- </table>
- <?php
- /*------------------*/
- /* Message d'erreur */
- /*------------------*/
- if ($reponse != "")
- echo "<div id=\"reponse\">$reponse</div>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement