Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*##################################################
- * status-commande-telephone.php
- * -------------------
- * Date : October 18, 2014
- * Auhtor : (C) janus57
- * Author URL : http://forum.easy-hebergement.fr/memberlist.php?mode=viewprofile&u=4319
- * For the member : TTCoque (http://forum.easy-hebergement.fr/memberlist.php?mode=viewprofile&u=7597)
- *
- ###################################################
- *
- * This work/program by janus57 is licensed under a Creative Commons Attribution-ShareAlike 3.0 France License.
- * More informations here : http://creativecommons.org/licenses/by-sa/3.0/fr/ or http://creativecommons.org/licenses/by-sa/3.0/
- *
- ###################################################*/
- ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
- <head>
- <meta charset="UTF-8">
- <title>Étape Suivi Commande</title>
- </head>
- <body>
- <?php
- // On verifie que $_GET['code'] existe
- if (isset($_GET['code'])) {
- $code = $_GET['code']; // $_GET['code'] devient $code
- }
- else { // Sinon en retourne une erreur et quitte le script PHP
- echo 'error';
- exit();
- }
- 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
- /* 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) */
- $link = mysqli_connect("localhost", "test", "test", "test");
- /* Vérification de la connexion */
- if (mysqli_connect_errno()) {
- printf("Échec de la connexion : %s\n", mysqli_connect_error());
- exit();
- }
- $query_unprotected = "SELECT * FROM ps_orders WHERE reference = $code"; //Requête SQL
- $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
- $result = mysqli_query($link, $query); // on va chercher dans la BDD avec la requête plus haut.
- 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) */
- echo 'OK|SON|'.$row['current_state'].'|SON|FIN|';
- }
- else { /* Sinon elle ne retourne rien donc KO */
- echo 'ko';
- }
- /* Libération des résultats */
- mysqli_free_result($result);
- /* Fermeture de la connexion */
- mysqli_close($link);
- }
- else { // Si $code n'est pas numérique
- echo 'Code non numérique';
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement