Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Projet_idaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Liang Wu
Projet_idaw
Commits
f2c359fe
Commit
f2c359fe
authored
Apr 03, 2020
by
Liang Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inscription
parent
ede81403
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
245 additions
and
38 deletions
+245
-38
.DS_Store
.DS_Store
+0
-0
RESTAPI.html
RESTAPI.html
+58
-0
connected.php
connected.php
+58
-0
home.php
home.php
+42
-0
index.php
index.php
+24
-38
journal.php
journal.php
+1
-0
signup.php
signup.php
+62
-0
No files found.
.DS_Store
View file @
f2c359fe
No preview for this file type
RESTAPI.html
0 → 100644
View file @
f2c359fe
<!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>
connected.php
0 → 100644
View file @
f2c359fe
</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'
);
}
?>
home.php
0 → 100644
View file @
f2c359fe
<?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
index.php
View file @
f2c359fe
<?php
require_once
(
'template_header.php'
);
require_once
(
'template_menu.php'
);
session_start
();
$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> -->
if
(
isset
(
$_SESSION
[
'login'
])){
header
(
'Location: home.php'
);
}
<!-- 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
?>
<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>
journal.php
View file @
f2c359fe
...
...
@@ -19,6 +19,7 @@
<th>
Aliment
</th>
<th>
Type
</th>
<th>
Date
</th>
<th>
Quantité
</th>
</tr>
</thead>
<tbody
id=
"t"
>
...
...
signup.php
0 → 100644
View file @
f2c359fe
<!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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment