Commit 917edd323153844ff474a8b81c81faea30441f19
1 parent
0b7b1139
api/carte/info
Showing
1 changed file
with
41 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +require_once("../commun.php"); | ||
4 | + | ||
5 | +verifierDroit(1); | ||
6 | + | ||
7 | +if (!donne("idCarte")) { | ||
8 | + retour("requete_malformee"); | ||
9 | +} | ||
10 | + | ||
11 | +// Vérfie si un utilisateur possède cette carte | ||
12 | +$requete = $db->prepare("SELECT login FROM Utilisateurs WHERE idCarte=?"); | ||
13 | +if (!$requete) { | ||
14 | + retour("erreur_bdd_preparee", ["message" => $db->error]); | ||
15 | +} | ||
16 | +$requete->bind_param("s", $_POST['idCarte']); | ||
17 | +if (!$requete->execute()) { | ||
18 | + retour("erreur_bdd", ["message" => $requete->error]); | ||
19 | +} | ||
20 | +$utilisateur = false; | ||
21 | +$requete->bind_result($utilisateur); | ||
22 | +$requete->fetch(); | ||
23 | +$requete->close(); | ||
24 | + | ||
25 | +// Vérfie si un client possède cette carte | ||
26 | +$requete = $db->prepare("SELECT idCarte FROM Clients WHERE idCarte=?"); | ||
27 | +if (!$requete) { | ||
28 | + retour("erreur_bdd_preparee", ["message" => $db->error]); | ||
29 | +} | ||
30 | +$requete->bind_param("s", $_POST['idCarte']); | ||
31 | +if (!$requete->execute()) { | ||
32 | + retour("erreur_bdd", ["message" => $requete->error]); | ||
33 | +} | ||
34 | +$client = false; | ||
35 | +$requete->bind_result($client); | ||
36 | +$requete->fetch(); | ||
37 | +$requete->close(); | ||
38 | + | ||
39 | +retour("ok", ["utilisateur" => $utilisateur, "client" => $client]); | ||
40 | + | ||
41 | +?> |