Commit df600147 authored by Liang Wu's avatar Liang Wu

index

parent f7dbc8e3
......@@ -4,69 +4,39 @@
</head>
<body>
<script type="text/javascript">
setCookie("jwt", "", 1);
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
</script>
<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">
// show home page
function showHomePage(){
<main role="main" class="container starter-template">
// validate jwt to verify access
var jwt = getCookie('jwt');
$.post("https://eden.imt-lille-douai.fr/~liang.wu/API_LOGIN/identite/validate_token.php", JSON.stringify({ jwt:jwt })).done(function(result) {
var html = <a href="home.php">;
$('#content').html(html);
})
}
// get or read cookie
function getCookie(cname){
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' '){
c = c.substring(1);
}
<div class="row">
<div class="col">
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
</script>
<!-- where prompt / messages will appear -->
<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
src="https://code.jquery.com/jquery-3.4.1.min.js"
......@@ -75,6 +45,11 @@ function getCookie(cname){
<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/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<!-- jquery scripts will be here -->
<script type="text/javascript">
$(document).ready(function() {
// will run if create identite form was submitted
......@@ -90,18 +65,14 @@ $(document).ready(function() {
contentType : 'application/json',
data : form_data,
success : function(result){
// show home page & tell the user it was a successful login
showHomePage();
$('#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. Email or password is incorrect.</div>");
login_form.find('input').val('');
}
// 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('');
}
});
return false;
});
});
</script>
......
......@@ -36,15 +36,32 @@
<label>Taille(cm)</label>
<input type='text' id='taille' name='taille' class="form-control" required/>
</div>
<div>
<label>Sexe</label>
<input type='text' id='sexe' name='sexe' class="form-control" required/>
<div>
<label> Homme
<input type="radio" name="sexe" id="M">
</label><br>
<label> Femme
<input type="radio" name="sexe" id="F">
</label>
</div>
</div>
<div>
<label>Niveau du sport</label>
<input type='text' id='niveau_du_sport' name='niveau_du_sport' class="form-control" required/>
<label>Niveau de pratique sportive</label>
<div>
<label> Bas
<input type="radio" name="niveau_du_sport" id="bas">
</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>
</div>
</div>
<!-- button to submit form -->
......
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