Commit 76c7c884 authored by Raulin's avatar Raulin
parents ff0431ae 5c91a8e4
No preview for this file type
...@@ -25,21 +25,21 @@ if( ...@@ -25,21 +25,21 @@ if(
!empty($data->login) && !empty($data->login) &&
!empty($data->password) && !empty($data->password) &&
!empty($data->pseudo) && !empty($data->pseudo) &&
!empty($data->âge) && !empty($data->age) &&
!empty($data->poids) && !empty($data->poids) &&
!empty($data->taille) && !empty($data->taille) &&
!empty($data->sexe) && !empty($data->sexe) &&
!empty($data->niveau_du_sport) !empty($data->niveaudusport)
){ ){
// set product property values // set product property values
$identite->login = $data->login; $identite->login = $data->login;
$identite->password = $data->password; $identite->password = $data->password;
$identite->pseudo = $data->pseudo; $identite->pseudo = $data->pseudo;
$identite->âge = $data->âge; $identite->age = $data->age;
$identite->poids = $data->poids; $identite->poids = $data->poids;
$identite->taille = $data->taille; $identite->taille = $data->taille;
$identite->sexe = $data->sexe; $identite->sexe = $data->sexe;
$identite->niveau_du_sport = $data->niveau_du_sport; $identite->niveaudusport = $data->niveaudusport;
if($identite->create()){ if($identite->create()){
// set response code - 201 created // set response code - 201 created
......
<?php <?php
// required headers // required headers
header("Access-Control-Allow-Origin: https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/"); header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8"); header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST"); header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600"); header("Access-Control-Max-Age: 3600");
...@@ -16,18 +16,29 @@ ...@@ -16,18 +16,29 @@
// instantiate user object // instantiate user object
$identite = new Identite($db); $identite = new Identite($db);
$login_exists = $identite->loginExists();
// get posted data // get posted data
$data = json_decode(file_get_contents("php://input")); $data = json_decode(file_get_contents("php://input"));
// set product property values // set product property values
$identite->login = $data->login; $identite->login = $data->login;
$identite->password = $data->password; $login_exists = $identite->loginExists();
// check if email exists and if password is correct // check if email exists and if password is correct
if($login_exists){ if($login_exists){
$password = $identite->password;
if($password==$data->password){
http_response_code(200); http_response_code(200);
echo json_encode(array("message" => "Successful login."));} echo json_encode(array(
"message" => "Successful login."
));
}
else{
http_response_code(401);
// tell the user login failed
echo json_encode(array("message" => "Mot de passe incorrect"));
}
}
// login failed // login failed
......
...@@ -40,11 +40,11 @@ if($num>0){ ...@@ -40,11 +40,11 @@ if($num>0){
"login" => $login, "login" => $login,
"password" => $password, "password" => $password,
"pseudo" => $pseudo, "pseudo" => $pseudo,
"âge" => ge, "age" => $age,
"poids" => $poids, "poids" => $poids,
"taille" => $taille, "taille" => $taille,
"sexe" => $sexe, "sexe" => $sexe,
"niveau_du_sport" =>$niveau_du_sport "niveaudusport" =>$niveaudusport
); );
array_push($identites_arr["records"], $identite_item); array_push($identites_arr["records"], $identite_item);
......
...@@ -18,23 +18,23 @@ $db = $database->getConnection(); ...@@ -18,23 +18,23 @@ $db = $database->getConnection();
$identite = new Identite($db); $identite = new Identite($db);
// set ID property of record to read // set ID property of record to read
$identite->id = isset($_GET['id']) ? $_GET['id'] : die(); $identite->login = isset($_GET['login']) ? $_GET['login'] : die();
// read the details of product to be edited // read the details of product to be edited
$identite->readOne(); $identite->readOne();
if($identite->login!=null){ if($identite->id!=null){
// create array // create array
$identite_arr = array( $identite_arr = array(
"id" => $identite->id, "id" => $identite->id,
"login" => $identite->login, "login" => $identite->login,
"password" => $identite->password, "password" => $identite->password,
"pseudo" => $identite->pseudo, "pseudo" => $identite->pseudo,
"âge" => $identite->âge, "age" => $identite->age,
"poids" => $identite->poids, "poids" => $identite->poids,
"taille" => $identite->taille, "taille" => $identite->taille,
"sexe" => $identite->sexe, "sexe" => $identite->sexe,
"niveau_du_sport" =>$identite->niveau_du_sport "niveaudusport" =>$identite->niveaudusport
); );
// set response code - 200 OK // set response code - 200 OK
......
...@@ -43,11 +43,11 @@ if($num>0){ ...@@ -43,11 +43,11 @@ if($num>0){
"login" => $login, "login" => $login,
"password" => $password, "password" => $password,
"pseudo" => $pseudo, "pseudo" => $pseudo,
"âge" => ge, "age" => $age,
"poids" => $poids, "poids" => $poids,
"taille" => $taille, "taille" => $taille,
"sexe" => $sexe, "sexe" => $sexe,
"niveau_du_sport" =>$niveau_du_sport "niveaudusport" =>$niveaudusport
); );
array_push($identites_arr["records"], $identite_item); array_push($identites_arr["records"], $identite_item);
......
...@@ -27,11 +27,11 @@ $identite->id = $data->id; ...@@ -27,11 +27,11 @@ $identite->id = $data->id;
$identite->login = $data->login; $identite->login = $data->login;
$identite->password = $data->password; $identite->password = $data->password;
$identite->pseudo = $data->pseudo; $identite->pseudo = $data->pseudo;
$identite->âge = $data->âge; $identite->age = $data->age;
$identite->poids = $data->poids; $identite->poids = $data->poids;
$identite->taille = $data->taille; $identite->taille = $data->taille;
$identite->sexe = $data->sexe; $identite->sexe = $data->sexe;
$identite->niveau_du_sport = $data->niveau_du_sport; $identite->niveaudusport = $data->niveaudusport;
// update the product // update the product
if($identite->update()){ if($identite->update()){
......
<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
// required to decode jwt
include_once '../config/core.php';
include_once '../libs/php-jwt-master/src/BeforeValidException.php';
include_once '../libs/php-jwt-master/src/ExpiredException.php';
include_once '../libs/php-jwt-master/src/SignatureInvalidException.php';
include_once '../libs/php-jwt-master/src/JWT.php';
use \Firebase\JWT\JWT;
// get posted data
$data = json_decode(file_get_contents("php://input"));
// get jwt
$jwt=isset($data->jwt) ? $data->jwt : "";
// if jwt is not empty
if($jwt){
// if decode succeed, show user details
try {
// decode jwt
$decoded = JWT::decode($jwt, $key, array('HS256'));
// set response code
http_response_code(200);
// show user details
echo json_encode(array(
"message" => "Access granted.",
"data" => $decoded->data
));
}
// if decode fails, it means jwt is invalid
catch (Exception $e){
// set response code
http_response_code(401);
// tell the user access denied & show error message
echo json_encode(array(
"message" => "Access denied.",
"error" => $e->getMessage()
));
}
}
// show error message if jwt is empty
else{
// set response code
http_response_code(401);
// tell the user access denied
echo json_encode(array("message" => "Access denied."));
}
?>
\ No newline at end of file
No preview for this file type
...@@ -9,11 +9,11 @@ class Identite{ ...@@ -9,11 +9,11 @@ class Identite{
public $login; public $login;
public $password; public $password;
public $pseudo; public $pseudo;
public $âge; public $age;
public $poids; public $poids;
public $taille; public $taille;
public $sexe; public $sexe;
public $niveau_du_sport; public $niveaudusport;
// constructor with $db as database connection // constructor with $db as database connection
public function __construct($db){ public function __construct($db){
...@@ -40,7 +40,7 @@ class Identite{ ...@@ -40,7 +40,7 @@ class Identite{
// query to check if email exists // query to check if email exists
$query = "SELECT * $query = "SELECT *
FROM $this->table_name FROM $this->table_name
WHERE login =:login AND password =: password WHERE login = ?
LIMIT 0,1"; LIMIT 0,1";
// prepare the query // prepare the query
...@@ -48,12 +48,9 @@ class Identite{ ...@@ -48,12 +48,9 @@ class Identite{
// sanitize // sanitize
$this->login=htmlspecialchars(strip_tags($this->login)); $this->login=htmlspecialchars(strip_tags($this->login));
$this->password=htmlspecialchars(strip_tags($this->password));
// bind given email value // bind given email value
$stmt->bindParam(':login', $this->login); $stmt->bindParam(1, $this->login);
$stmt->bindParam(':password', $this->password);
// execute the query // execute the query
$stmt->execute(); $stmt->execute();
...@@ -70,11 +67,11 @@ class Identite{ ...@@ -70,11 +67,11 @@ class Identite{
$this->id = $row['id']; $this->id = $row['id'];
$this->password = $row['password']; $this->password = $row['password'];
$this->pseudo = $row['pseudo']; $this->pseudo = $row['pseudo'];
$this->âge = $row[ge']; $this->age = $row['age'];
$this->poids = $row['poids']; $this->poids = $row['poids'];
$this->taille = $row['taille']; $this->taille = $row['taille'];
$this->sexe = $row['sexe']; $this->sexe = $row['sexe'];
$this->niveau_du_sport = $row['niveau_du_sport']; $this->niveaudusport = $row['niveaudusport'];
// return true because email exists in the database // return true because email exists in the database
return true; return true;
...@@ -90,9 +87,9 @@ class Identite{ ...@@ -90,9 +87,9 @@ class Identite{
// query to insert record // query to insert record
$query = "INSERT INTO $query = "INSERT INTO
" . $this->table_name . " ".$this->table_name."
SET SET
login=:login, password=:password, pseudo=:pseudo, âge=:âge, poids=:poids, taille=:taille, sexe=:sexe, niveau_du_sport=:niveau_du_sport"; login=:login, password=:password, pseudo=:pseudo, age=:age, poids=:poids, taille=:taille, sexe=:sexe, niveaudusport=:niveaudusport";
// prepare query // prepare query
$stmt = $this->conn->prepare($query); $stmt = $this->conn->prepare($query);
...@@ -101,21 +98,22 @@ class Identite{ ...@@ -101,21 +98,22 @@ class Identite{
$this->login=htmlspecialchars(strip_tags($this->login)); $this->login=htmlspecialchars(strip_tags($this->login));
$this->password=htmlspecialchars(strip_tags($this->password)); $this->password=htmlspecialchars(strip_tags($this->password));
$this->pseudo=htmlspecialchars(strip_tags($this->pseudo)); $this->pseudo=htmlspecialchars(strip_tags($this->pseudo));
$this->âge=htmlspecialchars(strip_tags($this->âge)); $this->age=htmlspecialchars(strip_tags($this->age));
$this->poids=htmlspecialchars(strip_tags($this->poids)); $this->poids=htmlspecialchars(strip_tags($this->poids));
$this->taille=htmlspecialchars(strip_tags($this->taille)); $this->taille=htmlspecialchars(strip_tags($this->taille));
$this->sexe=htmlspecialchars(strip_tags($this->sexe)); $this->sexe=htmlspecialchars(strip_tags($this->sexe));
$this->niveau_du_sport=htmlspecialchars(strip_tags($this->niveau_du_sport)); $this->niveaudusport=htmlspecialchars(strip_tags($this->niveaudusport));
// bind values // bind values
$stmt->bindParam(":login", $this->login); $stmt->bindParam(":login", $this->login);
$stmt->bindParam(":password", $this->password); $stmt->bindParam(":password", $this->password);
$stmt->bindParam(":pseudo", $this->pseudo); $stmt->bindParam(":pseudo", $this->pseudo);
$stmt->bindParam(":âge", $this->âge); $stmt->bindParam(":age", $this->age);
$stmt->bindParam(":poids", $this->poids); $stmt->bindParam(":poids", $this->poids);
$stmt->bindParam(":taille", $this->taille); $stmt->bindParam(":taille", $this->taille);
$stmt->bindParam(":sexe", $this->sexe); $stmt->bindParam(":sexe", $this->sexe);
$stmt->bindParam(":niveau_du_sport", $this->niveau_du_sport); $stmt->bindParam(":niveaudusport", $this->niveaudusport);
// execute query // execute query
if($stmt->execute()){ if($stmt->execute()){
...@@ -129,13 +127,13 @@ class Identite{ ...@@ -129,13 +127,13 @@ class Identite{
function readOne(){ function readOne(){
// query to read single record // query to read single record
$query = "SELECT * FROM $this->table_name WHERE id = ?"; $query = "SELECT * FROM $this->table_name WHERE login = ?";
// prepare query statement // prepare query statement
$stmt = $this->conn->prepare( $query ); $stmt = $this->conn->prepare( $query );
// bind id of product to be updated // bind id of product to be updated
$stmt->bindParam(1, $this->id); $stmt->bindParam(1, $this->login);
// execute query // execute query
$stmt->execute(); $stmt->execute();
...@@ -144,14 +142,14 @@ class Identite{ ...@@ -144,14 +142,14 @@ class Identite{
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
// set values to object properties // set values to object properties
$this->login = $row['login']; $this->id = $row['id'];
$this->password = $row['password']; $this->password = $row['password'];
$this->pseudo = $row['pseudo']; $this->pseudo = $row['pseudo'];
$this->âge = $row[ge']; $this->age = $row['age'];
$this->poids = $row['poids']; $this->poids = $row['poids'];
$this->taille = $row['taille']; $this->taille = $row['taille'];
$this->sexe = $row['sexe']; $this->sexe = $row['sexe'];
$this->niveau_du_sport = $row['niveau_du_sport']; $this->niveaudusport = $row['niveaudusport'];
//$this->besoin_en_calories = $row['besoin_en_calories']; //$this->besoin_en_calories = $row['besoin_en_calories'];
} }
// update the product // update the product
...@@ -161,17 +159,17 @@ class Identite{ ...@@ -161,17 +159,17 @@ class Identite{
$query = "UPDATE $query = "UPDATE
" . $this->table_name . " " . $this->table_name . "
SET SET
login = :login, login=:login,
password = :password, password=:password,
pseudo = :pseudo, pseudo=:pseudo,
âge = :âge, age=:age,
poids = :poids, poids=:poids,
taille = :taille, taille=:taille,
sexe = :sexe, sexe=:sexe,
niveau_du_sport = :niveau_du_sport niveaudusport=:niveaudusport
//besoin_en_calories =:besoin_en_calories //besoin_en_calories =:besoin_en_calories
WHERE WHERE
id = :id"; id=:id";
// prepare query statement // prepare query statement
$stmt = $this->conn->prepare($query); $stmt = $this->conn->prepare($query);
...@@ -181,11 +179,11 @@ class Identite{ ...@@ -181,11 +179,11 @@ class Identite{
$this->login=htmlspecialchars(strip_tags($this->login)); $this->login=htmlspecialchars(strip_tags($this->login));
$this->password=htmlspecialchars(strip_tags($this->password)); $this->password=htmlspecialchars(strip_tags($this->password));
$this->pseudo=htmlspecialchars(strip_tags($this->pseudo)); $this->pseudo=htmlspecialchars(strip_tags($this->pseudo));
$this->âge=htmlspecialchars(strip_tags($this->âge)); $this->age=htmlspecialchars(strip_tags($this->age));
$this->poids=htmlspecialchars(strip_tags($this->poids)); $this->poids=htmlspecialchars(strip_tags($this->poids));
$this->taille=htmlspecialchars(strip_tags($this->taille)); $this->taille=htmlspecialchars(strip_tags($this->taille));
$this->sexe=htmlspecialchars(strip_tags($this->sexe)); $this->sexe=htmlspecialchars(strip_tags($this->sexe));
$this->niveau_du_sport=htmlspecialchars(strip_tags($this->niveau_du_sport)); $this->niveaudusport=htmlspecialchars(strip_tags($this->niveaudusport));
//$this->besoin_en_calories=htmlspecialchars(strip_tags($this->besoin_en_calories)); //$this->besoin_en_calories=htmlspecialchars(strip_tags($this->besoin_en_calories));
...@@ -194,11 +192,11 @@ class Identite{ ...@@ -194,11 +192,11 @@ class Identite{
$stmt->bindParam(':login', $this->login); $stmt->bindParam(':login', $this->login);
$stmt->bindParam(':password', $this->password); $stmt->bindParam(':password', $this->password);
$stmt->bindParam(':pseudo', $this->pseudo); $stmt->bindParam(':pseudo', $this->pseudo);
$stmt->bindParam(':âge', $this->âge); $stmt->bindParam(':age', $this->age);
$stmt->bindParam(':poids', $this->poids); $stmt->bindParam(':poids', $this->poids);
$stmt->bindParam(':taille', $this->taille); $stmt->bindParam(':taille', $this->taille);
$stmt->bindParam(':sexe', $this->sexe); $stmt->bindParam(':sexe', $this->sexe);
$stmt->bindParam(':niveau_du_sport', $this->niveau_du_sport); $stmt->bindParam(':niveaudusport', $this->niveaudusport);
// $stmt->bindParam(':besoin_en_calories', $this->besoin_en_calories); // $stmt->bindParam(':besoin_en_calories', $this->besoin_en_calories);
......
File added
<?php
require_once('template_header.php');
?>
<script type="text/javascript">
$(document).ready( function() {
$.getJSON('https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/read.php',
function(json){
// console.log(json);
var table = <?php echo json_encode($users); ?>;
table.php('');
// cf. https://api.jquery.com/jQuery.getJSON/
$.each( json, function( key, val ) {
table.append(val['login']+'=>'+val['password']+',');
});
}
)
});
</script>
<?php
$users = array();
$login = "anonymous";
$errorText = "";
$successfullyLogged = false;
if(isset($_GET['login']) && isset($_GET['password'])){
$tryLogin=$_GET['login'];
$tryPwd=$_GET['password'];
//si le mdp est correct
if(array_key_exists($tryLogin,$users) && $users[$tryLogin]==$tryPwd){
$successfullyLogged = true;
$login = $tryLogin;
} else
$errorText = "Erreur de login/password1";
} else
$errorText = "Merci d'utiliser le formulaire de login";
if(!$successfullyLogged) {
echo $errorText;
} else {
session_start();
$_SESSION['login']=$login;
$_SESSION['password']=$password;
header('Location: home.php');
}
?>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require_once('template_header.php'); require_once('template_header.php');
require_once('template_menu.php'); require_once('template_menu.php');
$currentPageId='index'; $currentPageId='home';
if(isset($_GET['page'])){ if(isset($_GET['page'])){
$currentPageId=$_GET['page']; $currentPageId=$_GET['page'];
} }
......
<!doctype html>
<html>
<head>
</head>
<body>
<?php <?php
session_start(); require_once('template_header.php');
if(isset($_SESSION['login'])){
header('Location: home.php');
}
?> ?>
<form id="login_form" action="#" method="POST">
<table>
<tr>
<th>Login :</th>
<td><input type="text" id ='login' name="login"></td>
</tr>
<tr>
<th>Mot de passe :</th>
<td><input type="password" id='password' name="password"></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="Se connecter..." /></td>
</tr>
<tr>
<a href="signup.php">S'inscrire</a>
</tr>
</table>
</form>
<script type="text/javascript"> <main role="main" class="container starter-template">
// show home page
function showHomePage(){
// if valid, show homepage <div class="row">
var html = <a href="home.php">; <div class="col">
} <!-- where prompt / messages will appear -->
</script> <div id="response"></div>
<div>
<form id="login_form" method="POST">
<table>
<tr>
<th>Login :</th>
<td><input type="text" id ='login' name="login"></td>
</tr>
<tr>
<th>Mot de passe :</th>
<td><input type="password" id='password' name="password"></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="Se connecter..." /></td>
</tr>
<tr>
<a href="signup.php">S'inscrire</a>
</tr>
</table>
</form>
</div>
</div>
</div>
</main>
<script <script
src="https://code.jquery.com/jquery-3.4.1.min.js" src="https://code.jquery.com/jquery-3.4.1.min.js"
...@@ -50,14 +43,17 @@ var html = <a href="home.php">; ...@@ -50,14 +43,17 @@ var html = <a href="home.php">;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-serialize-object/2.5.0/jquery.serialize-object.min.js" ></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-serialize-object/2.5.0/jquery.serialize-object.min.js" ></script>
<script type="text/javascript"> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<!-- jquery scripts will be here -->
$(document).ready( function($) { <script type="text/javascript">
$(document).ready(function() {
// will run if create identite form was submitted // will run if create identite form was submitted
$(document).on('submit', '#login_form', function(){ $(document).on('submit', '#login_form', function(){
// get form data // get form data
var form_data=JSON.stringify($(this).serializeObject()); var form_data=JSON.stringify($(this).serializeObject());
// console.log(form_data);
// submit form data to api // submit form data to api
$.ajax({ $.ajax({
...@@ -66,14 +62,22 @@ $(document).ready( function($) { ...@@ -66,14 +62,22 @@ $(document).ready( function($) {
contentType : 'application/json', contentType : 'application/json',
data : form_data, data : form_data,
success : function(result){ success : function(result){
// show home page & tell the user it was a successful login var ac_log=JSON.parse(form_data);
showHomePage(); document.cookie ="IdentifiantActuel="+ac_log.login;
$('#response').html("<div class='alert alert-success'>Successful login.</div>"); window.location="https://eden.imt-lille-douai.fr/~liang.wu/projet_idaw/home.php";
},
error: function(xhr, resp, text){
// on error, tell the user login has failed & empty the input boxes
$('#response').html("<div class='alert alert-danger'>Login failed. login or password is incorrect.</div>");
login_form.find('input').val('');
} }
}); });
}); });
}); });
</script> </script>
</body>
</html> <?php
\ No newline at end of file require_once('template_footer.php');
?>
\ No newline at end of file
<section> <head>
<h2>Charlotte Raulin</h2> <meta charset="utf-8"/>
<img src="logo.png" alt="" height="90px" width="150px"/><br> <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<label> Age : < 40 </label><br> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css">
<label> Sexe : Femme </label><br>
<label> Niveau de pratique sportive : Bas </label> <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#table_info').DataTable();
} );
</script>
<script type="text/javascript">
$(document).ready( function() {
// $ident= getCookie("IdentifiantActuel");
$.getJSON('https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/read.php',
function(data){
table = $('#tbody_info');
table.html('');
$.each( data.records, function( key, val ) {
table.append('<tr><td>'+val.id+'</td><td>'+val.login+'</td><td>'+val.password+'</td><td>'+val.pseudo+'</td><td>'+val.age+'</td><td>'+val.poids+'</td><td>'+val.taille+'</td><td>'+val.sexe+'</td><td>'+val.niveaudusport+'</td></tr>');
});
}
);
</script>
</head>
<section id="profil_contenu" style="display : flex; flex-direction : row; ">
<div style="margin-right:100px">
<table id="table_info" class="dataTable" style="color : #212529; ">
<thead>
<tr>
<th>id</th>
<th>login</th>
<th>password</th>
<th>pseudo</th>
<th>âge</th>
<th>poids(kg)</th>
<th>taille(cm)</th>
<th>sexe</th>
<th>niveau_du_sport</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tbody_info"><tbody>
</table>
</div>
</section> </section>
\ No newline at end of file
<!doctype html> <?php
<html> require_once('template_header.php');
<head> ?>
</head>
<body> <section>
<div id="response"></div>
<div><a href="index.php">Se connecter</a></div>
</section>
<section>
<!-- 'create identite' html form --> <!-- 'create identite' html form -->
<form id='creation' action='#' method='post' > <form id="form_signup" action="#" method="POST" >
<table class='table_signup'> <div>
<tr> <label>Login</label>
<td>Login</td> <input type='text' id='login' name='login' class="form-control" required />
<td><input type='text' name='login' class='form-control' required /></td> </div>
</tr>
<div>
<tr> <label>Password</label>
<td>Password</td> <input type='text' id='password' name='password' class="form-control" required />
<td><input type='text' name='password' class='form-control' required /></td> </div>
</tr>
<div>
<tr> <label>Pseudo</label>
<td>Pseudo</td> <input type='text' id='pseudo' name='pseudo' class="form-control" required/>
<td><input type='text' name='pseudo' class='form-control' required/></td> </div>
</tr>
<div>
<tr> <label>Âge</label>
<td>Age</td> <input type='text' id='age' name='age' class="form-control" required />
<td><input type='text' name='âge' class='form-control' required/></td> </div>
</tr>
<div>
<tr> <label>Poids(kg)</label>
<td>Poids(kg)</td> <input type='text' id='poids' name='poids' class="form-control" required/>
<td><input type='text' name='poids' class='form-control' required/></td> </div>
</tr>
<div>
<tr> <label>Taille(cm)</label>
<td>Taille(cm)</td> <input type='text' id='taille' name='taille' class="form-control" required/>
<td><input type='text' name='taille' class='form-control' required/></td> </div>
</tr>
<div class="form-group">
<tr> <label>Sexe</label>
<td>Sexe</td> <select class="form-control" id="sexe" name="sexe">
<td> <option selected>Choisir...</option>
<label> Homme <option>Femme</option>
<input type="radio" name="sexe" id="M"> <option>Homme</option>
</label><br> </select>
<label> Femme </div>
<input type="radio" name="sexe" id="F">
</label> <div class="form-group">
</td> <label>Niveau de sport</label>
</tr> <select class="form-control" id="niveaudusport" name="niveaudusport">
<option selected>Choisir...</option>
<tr> <option>Bas</option>
<td>Niveau de pratique sportive</td> <option>Moyen</option>
<td> <option>Elevé</option>
<label> Bas </select>
<input type="radio" name="niveau_du_sport" id="bas"> </div>
</label><br>
<label> Moyen
<input type="radio" name="niveau_du_sport" id="moyen">
</label><br>
<label> Elevé
<input type="radio" name="niveau_du_sport" id="eleve">
</label>
</td>
</tr>
<!-- button to submit form --> <!-- button to submit form -->
<tr> </div>
<td></td> <div class="form-action-buttons">
<td> <input type="submit" value="Créer">
<button type='submit' class='submit'>créer</button> </div>
</td>
</tr>
</table>
</form> </form>
<script <script
src="https://code.jquery.com/jquery-3.4.1.min.js" src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
...@@ -85,7 +79,7 @@ ...@@ -85,7 +79,7 @@
$(document).ready( function($) { $(document).ready( function($) {
// will run if create identite form was submitted // will run if create identite form was submitted
$(document).on('submit', '#creation', function(){ $(document).on('submit', '#form_signup', function(){
// get form data // get form data
var form_data=JSON.stringify($(this).serializeObject()); var form_data=JSON.stringify($(this).serializeObject());
// console.log(form_data); // console.log(form_data);
...@@ -95,10 +89,26 @@ $(document).ready( function($) { ...@@ -95,10 +89,26 @@ $(document).ready( function($) {
url: "https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/create.php", url: "https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/create.php",
type : "POST", type : "POST",
contentType : 'application/json', contentType : 'application/json',
data : form_data data : form_data,
success : function(result){
$('#response').html("<div class='alert alert-danger'>success.</div>");
},
error: function(xhr, resp, text){
// on error, tell the user login has failed & empty the input boxes
$('#response').html("<div class='alert alert-danger'>failed</div>");
login_form.find('input').val('');
}
}); });
}); });
}); });
</script> </script>
</body>
</html> </section>
\ No newline at end of file
<?php
require_once('template_footer.php');
?>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// un tableau qui d\'efinit la structure du site // un tableau qui d\'efinit la structure du site
$mymenu = array( $mymenu = array(
// idPage titre // idPage titre
'index' => array( 'Accueil' ), 'home' => array( 'Accueil' ),
'profil_affichage' => array( 'Profil' ), 'profil_affichage' => array( 'Profil' ),
'profil_modif' => array( 'Modifier mon profil' ), 'profil_modif' => array( 'Modifier mon profil' ),
'aliments' => array('Aliments'), 'aliments' => array('Aliments'),
...@@ -23,7 +23,7 @@ foreach($mymenu as $pageId => $pageParameters) { ...@@ -23,7 +23,7 @@ foreach($mymenu as $pageId => $pageParameters) {
$id=""; $id="";
} }
echo ' <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"'.$id.' href= "index.php?page='.$pageId.'">'.$pageParameters[0].'</a></li>'; echo ' <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"'.$id.' href= "home.php?page='.$pageId.'">'.$pageParameters[0].'</a></li>';
} }
echo '</ul> </div> </div> </nav>'; echo '</ul> </div> </div> </nav>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment