Commit f2c359fe authored by Liang Wu's avatar Liang Wu

inscription

parent ede81403
No preview for this file type
<!doctype html> <html>
<head>
<title id="hearts">Site web</title>
<link rel="stylesheet" href="bootstrap/css/freelancer.css" type="text/css"
media="screen" title="default" charset="utf-8" /> </head>
<header>
Documentation API (Charlotte Raulin et Liang WU)
</header>
<body>
<p>Le REST endpoint est https://eden.imt-lille-douai.fr/~prenom.nom/projet_idaw </p>
<p></p>
<table>
<thead>
<tr>
<th>Action</th>
<th>HTTP</th>
<th>Payload</th>
<th>URL</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Afficher</td>
<td>GET</td>
<td></td>
<td>/aliments</td>
<td>Permet d'afficher la liste des aliments </td>
</tr>
<tr>
<td>Ajouter</td>
<td>POST</td>
<td>json</td>
<td>/aliments</td>
<td>Permet d'ajouter un aliment </td>
</tr>
<tr>
<td>Supprimer</td>
<td>DELETE</td>
<td></td>
<td>/aliments/id</td>
<td>Permet de supprimer un aliment de la liste des aliments </td>
</tr>
<tr>
<td>Modifier</td>
<td>PUT</td>
<td>json</td>
<td>/aliments/id</td>
<td>Permet de modifier un aliment </td>
</tr>
</tbody>
</table>
</body>
</html>
</script>
<script type="text/javascript">
$(document).ready( function() {
$.getJSON('https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/read.php',
function(json){
// cf. https://api.jquery.com/jQuery.getJSON/
$.each( json, function( key, val ) {
var login = val[1],
var password = val[2]
});
}
)
});
</script>
<?php
// on se connecte à la bdd
require_once('template_header.php');
$login = "anonymous";
$errorText = "";
$successfullyLogged = false;
if(isset($_POST['login']) && isset($_POST['password'])){
$tryLogin=$_POST['login'];
$tryPwd=$_POST['password'];
//si login existe
if($result->num_rows != 0) {
$identite=$result->fetch_assoc();
//si le mdp est correct
if($identite['PASSWORD']==$tryPwd){
$successfullyLogged = true;
$login = $tryLogin;
$password = $tryPwd;
} else
$errorText = "Erreur de login/password1";
} else
$errorText = "Erreur de login/password2";
} 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');
}
?>
<?php
require_once('template_header.php');
require_once('template_menu.php');
$currentPageId='index';
if(isset($_GET['page'])){
$currentPageId=$_GET['page'];
}
?>
<!-- <header>
<h1 class="titre"><?php echo $mymenu[$currentPageId][0] ?> </h1>
<img src=<?php $currentPageId.".png" ?> alt="" height="90px" width="150px"/>
</header> -->
<header class="masthead bg-primary text-white text-center">
<div class="container d-flex align-items-center flex-column">
<!-- Masthead Heading -->
<!-- <h2 class="masthead-heading text-uppercase mb-0"><?php echo $mymenu[$currentPageId][0] ?></h2> -->
<!-- Masthead Subheading -->
<p class="masthead-subheading font-weight-light mb-0"> <div class="contenu">
<?php
$pageToInclude = $currentPageId . ".php";
if(is_readable($pageToInclude))
require_once($pageToInclude);
else
require_once("error.php");
?>
</div></p>
</div>
</header>
<?php
renderMenuToHTML($currentPageId);
?>
<?php
require_once('template_footer.php');
?>
\ No newline at end of file
<?php <?php
require_once('template_header.php'); session_start();
require_once('template_menu.php');
$currentPageId='index'; if(isset($_SESSION['login'])){
if(isset($_GET['page'])){ header('Location: home.php');
$currentPageId=$_GET['page'];
} }
?>
<!-- <header>
<h1 class="titre"><?php echo $mymenu[$currentPageId][0] ?> </h1>
<img src=<?php $currentPageId.".png" ?> alt="" height="90px" width="150px"/>
</header> -->
<header class="masthead bg-primary text-white text-center">
<div class="container d-flex align-items-center flex-column">
<!-- Masthead Heading -->
<!-- <h2 class="masthead-heading text-uppercase mb-0"><?php echo $mymenu[$currentPageId][0] ?></h2> -->
<!-- Masthead Subheading -->
<p class="masthead-subheading font-weight-light mb-0"> <div class="contenu">
<?php
$pageToInclude = $currentPageId . ".php";
if(is_readable($pageToInclude))
require_once($pageToInclude);
else
require_once("error.php");
?>
</div></p>
</div>
</header>
<?php
renderMenuToHTML($currentPageId);
?>
<?php
require_once('template_footer.php');
?> ?>
<form id="login_form" action="connected.php" 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" if='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>
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<th>Aliment</th> <th>Aliment</th>
<th>Type</th> <th>Type</th>
<th>Date</th> <th>Date</th>
<th>Quantité</th>
</tr> </tr>
</thead> </thead>
<tbody id="t"> <tbody id="t">
......
<!doctype html>
<html>
<head>
</head>
<body>
<!-- 'create identite' html form -->
<form id='creation' action='#' method='post' >
<table class='table_signup'>
<tr>
<td>Login</td>
<td><input type='text' name='login' class='form-control' required /></td>
</tr>
<tr>
<td>Password</td>
<td><input type='text' name='password' class='form-control' required /></td>
</tr>
<tr>
<td>Pseudo</td>
<td><input type='text' name='pseudo' class='form-control' required/></td>
</tr>
<!-- button to submit form -->
<tr>
<td></td>
<td>
<button type='submit' class='submit'>créer</button>
</td>
</tr>
</table>
</form>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></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">
$(document).ready( function($) {
// will run if create identite form was submitted
$(document).on('submit', '#creation', function(){
// get form data
var form_data=JSON.stringify($(this).serializeObject());
// console.log(form_data);
// submit form data to api
$.ajax({
url: "https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/create.php",
type : "POST",
contentType : 'application/json',
data : form_data
});
});
});
</script>
</body>
</html>
\ No newline at end of file
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