Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EDIT BY THOMMY -> NEW CODE
- ini_set('display_errors', 1); // DEBUG
- ini_set('display_startup_errors', 1); // DEBUG
- error_reporting(E_ALL); // AUSGABE FEHLER->ALLE
- $auth_code = filter_input(INPUT_GET, "authcode", FILTER_SANITIZE_STRING);// SANITIZE STRING
- $hash_tag = filter_input(INPUT_GET, "hash_tag", FILTER_SANITIZE_STRING);// SANITIZE STRING
- $tour_id = filter_input(INPUT_GET, "tour_id", FILTER_SANITIZE_STRING);// SANITIZE STRING
- // Wenn Tour_ID dann nimm Tour ID ansonsten nimm eine neue !
- $tour_id = ($tour_id == "") ? "1" : $tour_id; // Kommt von Client
- $auth_code = ($auth_code == "") ? "1" : $auth_code; // Kommt vom Client
- $auth_code2 = "2"; // Wenn kein Auth_Code vorhanden dann den
- // Abfrage ob es den Hash Code in Verbindung mit dem AuthCode schon gibt
- $anz = $pdo->prepare("SELECT * FROM tour_table WHERE hash_tag = ? AND auth_code = ? AND tour_id = ?");
- $anz->execute(array($hash_tag, $auth_code, $tour_id));
- // Wenn es 1 oder mehr Einträge gibt dann:
- if($anz->rowCount() >= 1) {
- echo "<br>Code ".$hash_tag." vorhanden -> Versuche ein Update...";
- $sql = $pdo->prepare("UPDATE tour_table SET auth_code = :auth_code WHERE hash_tag = :hash_tag");
- $sql->bindParam(":auth_code", $auth_code2);
- $sql->bindParam(":hash_tag", $hash_tag);
- try {
- $sql->execute();
- echo "<br>Update gemacht !";
- } catch (Exception $e1) {
- echo "<br>Fehler: ".$e1->getMessage();
- }
- // Ansonsten mache Neueintrag:
- } else {
- echo "<br>Code ".$hash_tag." fehlt -> Versuche Neueintrag...";
- $sql = $pdo->prepare("INSERT INTO tour_table (hash_tag, tour_id, auth_code) VALUES (:hash_tag, :tour_id, :auth_code)");
- $sql->bindParam(":auth_code", $auth_code);
- $sql->bindParam(":hash_tag", $hash_tag);
- $sql->bindParam(":tour_id", $tour_id);
- try {
- $sql->execute();
- echo "<br>Neueintragung gemacht !";
- } catch (Exception $e2) {
- echo "<br>Fehler: ".$e2->getMessage();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement