<?php // required headers header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: access"); header("Access-Control-Allow-Methods: GET"); header("Access-Control-Allow-Credentials: true"); header('Content-Type: application/json'); // include database and object files include_once '../config/database.php'; include_once '../objects/identite.php'; // get database connection $database = new Database(); $db = $database->getConnection(); // prepare product object $identite = new Identite($db); // set ID property of record to read $identite->login = isset($_GET['login']) ? $_GET['login'] : die(); // read the details of product to be edited $identite->readOne(); if($identite->id!=null){ // create array $identite_arr = array( "id" => $identite->id, "login" => $identite->login, "password" => $identite->password, "pseudo" => $identite->pseudo, "age" => $identite->age, "poids" => $identite->poids, "taille" => $identite->taille, "sexe" => $identite->sexe, "niveaudusport" =>$identite->niveaudusport, "icalories" => $identite->icalories ); // set response code - 200 OK http_response_code(200); // make it json format echo json_encode($identite_arr); } else{ // set response code - 404 Not found http_response_code(404); // tell the user product does not exist echo json_encode(array("message" => "Cet identifiant n'existe pas.")); } ?>