Advertisement
janus57

status-commande-telephone.php

Oct 18th, 2014
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. <?php
  2. /*##################################################
  3.  *                      status-commande-telephone.php
  4.  *                      -------------------
  5.  *  Date                : October 18, 2014
  6.  *  Auhtor              : (C) janus57
  7.  *  Author URL          : http://forum.easy-hebergement.fr/memberlist.php?mode=viewprofile&u=4319
  8.  *  For the member      : TTCoque (http://forum.easy-hebergement.fr/memberlist.php?mode=viewprofile&u=7597)
  9.  *
  10.  ###################################################
  11.  *
  12.  * This work/program by janus57 is licensed under a Creative Commons Attribution-ShareAlike 3.0 France License.
  13.  * More informations here : http://creativecommons.org/licenses/by-sa/3.0/fr/ or http://creativecommons.org/licenses/by-sa/3.0/
  14.  *
  15.  ###################################################*/
  16. ?>
  17. <!DOCTYPE html>
  18. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  19.     <head>
  20.         <meta charset="UTF-8">
  21.         <title>Étape Suivi Commande</title>
  22.     </head>
  23. <body>
  24. <?php
  25. // On verifie que $_GET['code'] existe
  26. if (isset($_GET['code'])) {
  27. $code = $_GET['code']; // $_GET['code'] devient $code
  28. }
  29. else { // Sinon en retourne une erreur et quitte le script PHP
  30.     echo 'error';
  31.     exit();
  32. }
  33.  
  34. if (is_numeric($code)) { // On verifie que $code est numéric (évite bien des problème si jamais la page est trouvé par une personne malveillante
  35. /* Connexion à la BDD | mysqli_connect('adresse_serveur_sql', 'user_sql', 'mot-de-passe_sql', 'nom-de-la-BDD') (Cf : http://fr.php.net/manual/fr/mysqli.construct.php) */
  36. $link = mysqli_connect("localhost", "test", "test", "test");
  37.  
  38. /* Vérification de la connexion */
  39. if (mysqli_connect_errno()) {
  40.     printf("Échec de la connexion : %s\n", mysqli_connect_error());
  41.     exit();
  42. }
  43.  
  44. $query_unprotected = "SELECT * FROM ps_orders WHERE reference = $code"; //Requête SQL
  45. $query = mysqli_real_escape_string($link, $query_unprotected); // on protège la requête (on ne sais jamais) Cf : http://fr.php.net/manual/fr/mysqli.real-escape-string.php
  46. $result = mysqli_query($link, $query); // on va chercher dans la BDD avec la requête plus haut.
  47.  
  48. if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { /* Si la requ^te retourne un tableau associatif (Cf : http://fr.php.net/manual/fr/mysqli-result.fetch-array.php) */
  49. echo 'OK|SON|'.$row['current_state'].'|SON|FIN|';
  50. }
  51. else { /* Sinon elle ne retourne rien donc KO */
  52. echo 'ko';
  53. }
  54.  
  55. /* Libération des résultats */
  56. mysqli_free_result($result);
  57.  
  58. /* Fermeture de la connexion */
  59. mysqli_close($link);
  60. }
  61. else { // Si $code n'est pas numérique
  62.     echo 'Code non numérique';
  63. }
  64. ?>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement