Advertisement
thommy1972de2

VTC1

Feb 18th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. // EDIT BY THOMMY -> NEW CODE
  2. ini_set('display_errors', 1); // DEBUG
  3. ini_set('display_startup_errors', 1); // DEBUG
  4. error_reporting(E_ALL); // AUSGABE FEHLER->ALLE
  5.  
  6. $auth_code = filter_input(INPUT_GET, "authcode", FILTER_SANITIZE_STRING);// SANITIZE STRING
  7. $hash_tag = filter_input(INPUT_GET, "hash_tag", FILTER_SANITIZE_STRING);// SANITIZE STRING
  8. $tour_id = filter_input(INPUT_GET, "tour_id", FILTER_SANITIZE_STRING);// SANITIZE STRING
  9.  
  10. // Wenn Tour_ID dann nimm Tour ID ansonsten nimm eine neue !
  11. $tour_id = ($tour_id == "") ? "1" : $tour_id;  // Kommt von Client
  12. $auth_code = ($auth_code == "") ? "1" : $auth_code; // Kommt vom Client
  13. $auth_code2 = "2"; // Wenn kein Auth_Code vorhanden dann den
  14.  
  15.  
  16.  
  17. // Abfrage ob es den Hash Code in Verbindung mit dem AuthCode schon gibt
  18. $anz = $pdo->prepare("SELECT * FROM tour_table WHERE hash_tag = ? AND auth_code = ? AND tour_id = ?");
  19. $anz->execute(array($hash_tag, $auth_code, $tour_id));
  20.  
  21. // Wenn es 1 oder mehr Einträge gibt dann:
  22. if($anz->rowCount() >= 1) {
  23.     echo "<br>Code ".$hash_tag." vorhanden -> Versuche ein Update...";
  24.         $sql = $pdo->prepare("UPDATE tour_table SET auth_code = :auth_code WHERE hash_tag = :hash_tag");
  25.         $sql->bindParam(":auth_code", $auth_code2);
  26.         $sql->bindParam(":hash_tag", $hash_tag);
  27.         try {
  28.             $sql->execute();
  29.             echo "<br>Update gemacht !";
  30.         } catch (Exception $e1) {
  31.         echo "<br>Fehler: ".$e1->getMessage();
  32.         }
  33.        
  34.         // Ansonsten mache Neueintrag:
  35.     } else {
  36.         echo "<br>Code ".$hash_tag." fehlt -> Versuche Neueintrag...";
  37.         $sql = $pdo->prepare("INSERT INTO tour_table (hash_tag, tour_id, auth_code) VALUES (:hash_tag, :tour_id, :auth_code)");
  38.         $sql->bindParam(":auth_code", $auth_code);
  39.         $sql->bindParam(":hash_tag", $hash_tag);
  40.         $sql->bindParam(":tour_id", $tour_id);
  41.         try {
  42.             $sql->execute();
  43.             echo "<br>Neueintragung gemacht !";
  44.         } catch (Exception $e2) {
  45.         echo "<br>Fehler: ".$e2->getMessage();
  46.         }
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement