function loadInfoPers($IDpers) { $bdd = connectBDD(); $response = $bdd->query("SELECT Personne.nom_Pers AS nom, Personne.prenom_Pers AS prenom, Personne.birthdate_Pers AS birthdate, Personne.address_Pers AS adress, Ville.cp_Ville AS codePostal, Ville.localite_Ville AS ville FROM Personne NATURAL JOIN Ville WHERE Personne.ID_Pers = " . $IDpers); while ($donnee = $response->fetch()) { $infoPerson['nom'] = $donnee['nom']; $infoPerson['prenom'] = $donnee['prenom']; $infoPerson['birthdate'] = $donnee['birthdate']; $infoPerson['adress'] = $donnee['adress']; $infoPerson['codePostal'] = $donnee['codePostal']; $infoPerson['ville'] = $donnee['ville']; } $response = $bdd->query("SELECT MoyenCom.libelle_MoyenCom AS moyenCom, MoyenCom_Personne.info AS infoCom FROM Personne NATURAL JOIN MoyenCom_Personne NATURAL JOIN MoyenCom WHERE ID_Pers = " . $IDpers); while ($donnee = $response->fetch()) { if ($donnee['moyenCom'] == "Email") { $infoPerson['email'] = $donnee['infoCom']; } if ($donnee['moyenCom'] == "Telephone") { $infoPerson['tel'] = $donnee['infoCom']; } } $infoPerson['time'] = colorBirthdate($infoPerson['birthdate']); return $infoPerson; }
<?php include 'message.php'; include 'connect.php'; include 'session.php'; error_reporting(0); connectBDD(); $json = json_decode(file_get_contents("php://input"), true); $login = $json['login']; $password = $json['password']; /* for test */ //$json = '{ "login": "******", "password": "******" }'; //$parsed_json = json_decode($json); //$login = $parsed_json -> {'login'}; //$password = $parsed_json -> {'password'}; $result = mysql_query("SELECT * FROM USER WHERE mail = '" . $login . "'"); $logOk = false; $passOk = false; $row = mysql_fetch_assoc($result); /* If login exist */ if ($row['mail'] == $login && $login != null) { $logOk = true; } else { $response = getJSONFromCodeError(300); } /* If password is correct with good login */ if ($logOk && $row['password'] == $password) { $passOk = true; } else { if ($logOk && $row['password'] != $password) { $response = getJSONFromCodeError(301);
<?php require_once 'config.php'; require_once 'fonction.php'; $login = $_POST["login"]; $mdp = $_POST["password"]; echo "<center> {$login} {$mdp} </center>"; echo "host: " . $host . "\n"; echo "dbname: " . $database . "\n"; echo "login: "******"\n"; echo "mdp: " . $password . "\n"; $bdd = connectBDD($host, $database, $user, $password); if (assert('$login') && assert($password)) { $mdp = hash("sha256", $mdp); echo $mdp; addUser($login, $mdp, $bdd); echo "<center> Utilisateur enregistré</center>"; }
<?php include 'message.php'; include 'connect.php'; include 'session.php'; error_reporting(0); /* ########################### * MAIN ACTION * ########################### */ $connexion = connectBDD(); /* $jsonString = '{ "request": "removeUserFromGroup", "data": {"user_id":481} }'; $jsonString = '{ "request": "addUserToGroup", "data": {"user_id":481,"group_id":9} }'; $jsonString = '{ "request": "getUsersUngroup", "data": {} }'; $jsonString = '{ "request": "removeGroup", "data": {"group_id":9} }'; $jsonString = '{ "request": "createGroup", "data": {"group_name":"nouveau groupe"} }';
function connexion($login, $mdpC) { if (connectBDD($bdd)) { $requeteSQL = "SELECT login, nom, prenom, mdpCrypt, lienHypper FROM login WHERE login = '******'"; $reponse = $bdd->query($requeteSQL); if ($reponse->rowCount() != 0) { $donnee = $reponse->fetch(); if ($donnee["mdpCrypt"] == crypt($mdpC, "sdf589^ùd!@35d")) { $_SESSION['connecte'] = true; $_SESSION['login'] = $donnee["login"]; $_SESSION['lienHyper'] = $donnee["lienHypper"]; $_SESSION['nom'] = $donnee["nom"]; $_SESSION['prenom'] = $donnee["prenom"]; $_SESSION['planning_en_cours'] = ""; header('location: ./planning.php'); } else { $_SESSION["login_exe"] = $login; return "Mot de passe incorrect"; } } else { return "Cet utilisateur n'existe pas."; } } else { $reponse->closeCursor(); echo "ERREUR DE CONNEXION À LA BASE DE DONNÉE"; } }
} break; /** * listeMatiere : Fonction qui renvoi la liste des matières * Entrées: * Sorties: * Tableau Json avec toutes les matières */ /** * listeMatiere : Fonction qui renvoi la liste des matières * Entrées: * Sorties: * Tableau Json avec toutes les matières */ case "listeMatiere": if (connectBDD($bdd)) { $requeteSQL = "SELECT ID, nom, abreviation FROM matières ORDER BY ID ASC"; $reponse = $bdd->query($requeteSQL); $donnee = $reponse->fetch(); $i = 0; while ($donnee = $reponse->fetch()) { $i++; foreach ($donnee as $key => $value) { // on stock les resultats obtenue dans le tableau qui sera retourné en json if (!is_int($key)) { //le tableau renvoyer possède des id entier et des clé donc on ne prend que les clé $return[$i][$key] = utf8_encode($value); } } } $return["total"] = $i;