Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9055087d00 | |||
| 36234a5256 | |||
| 78caabe3f1 | |||
| 691f55f9d0 | |||
| a4580652f8 | |||
| 045ec81ae2 | |||
| 3c100c0200 | |||
| 5ef7c7b630 | |||
| c165b74c99 | |||
| 91524fb5e5 | |||
| e51a65fe0f | |||
| 07aad62741 | |||
| f1c7bd6bf7 | |||
| d13f66226b | |||
| 19afef54e6 | |||
| cb9ee07b87 | |||
| eb2d8315f9 | |||
| 8b5744084a | |||
| e401d54f6d | |||
| f33dcbbc7f | |||
| 54da0eae1b | |||
| 0bccb2e3a3 | |||
| ca8ce10644 | |||
| ce835fb93c | |||
| 88af050bea | |||
| 2373233899 | |||
| 8239d8024d | |||
| 1586d02094 | |||
| 2fe4bab887 | |||
| eb792edb4d | |||
| 1a450491c6 | |||
| a472e34bbe | |||
| 0490924e3d | |||
| db7896d2de | |||
| bd2243e28a | |||
| 1c7d7f636a | |||
| 1fe20f3f3b | |||
| 7f4884a90d | |||
| 532f73309c | |||
| 129a0c321c | |||
| ef4ddb1420 | |||
| da6a720f46 | |||
| 6d7a783d73 | |||
| 6cb1a005fd | |||
| d99fa137ec | |||
| 534fc8ace1 | |||
| 783e91969c | |||
| 226c55aca3 | |||
| 755c3d4e2e | |||
| c875a397ad | |||
| 5034bf1248 | |||
| 322c2a7e7f | |||
| 7aa9c51104 | |||
| 324f310e38 | |||
| 8536d0b1bb | |||
| 186b3839f0 | |||
| 9b8aed62a7 | |||
| 0df1e71aeb | |||
| dae058c2d4 | |||
| 657bfa1cba | |||
| 62899046bf | |||
| bd3bd96e15 | |||
| d70e783828 | |||
| be8b700896 | |||
| 3faf918ccc | |||
| f65b0c9155 | |||
| 7270567d8e | |||
| 720901218d | |||
| 6a36d1a457 | |||
| f86c52ff0e | |||
| c5f880e4f9 | |||
| 8951724e20 | |||
| b757e0ae78 | |||
| 9c3a22382f | |||
| 262e763b45 | |||
| 504b4e87ec | |||
| 9710d1a6cf |
@@ -15,5 +15,21 @@
|
||||
- MERIGOT Antoine / SLIMANI Tajeddine / DUCOURE Ibrahim
|
||||
- GILLET Noa / GUINET Djibril / SALVIA Tim
|
||||
- Anthony LIROT / Dylan SOYER
|
||||
- Emile Ta / Imad Mokhtari / Anthony Millerioux
|
||||
- Emile Ta / Imad Mokhtari / Anthony Millerioux / Johan Garnier
|
||||
- Matéo POUGET / Nathan LAUNAY / Ender PRADAT-DE CAROLIS
|
||||
- Fabien SELON / Michaellah LAHIKOA / Koutoub Khan KADARALY
|
||||
- Clement JACKSON GONZALEZ / Rayane MOUHIB / Dayann Sidiqui
|
||||
- Jossé Maël / Jihad Ghandri / Jdoudi Abderrahmane
|
||||
- Antoine BERNARD / Antoine MERCIER / Mathias PLACIDE CONTRERAS
|
||||
- Amrouchi Youssef / Maël Hamon / Baptiste Lecointre
|
||||
- Bradney LELIEVRE / Arif MOHAMED
|
||||
- Salgeiro da silva / Pelini / Janicot
|
||||
- Kenzo BONNET, Bryan Benhamou, Toni LAURENT
|
||||
- Mohamed Ouissi / Jabrail Mustaev / Talbi Sofiane
|
||||
- Aktas / Gobe / Tafok
|
||||
- CHARRIERE Nicolas / BODOL Mathis / TCHISSAFOU Yann-sulivane
|
||||
- Matie BAMBA
|
||||
- Colombani Loïc / Badio Ousmane
|
||||
- Adrien Jackson-Gonzalez / Gomez / Dimambu-Bola
|
||||
- Fabien SELON / Michaëllah LAHIKOA / Qoutoub Khan KADARALY
|
||||
- Kelyan Pierre-Louis / Jordan Arstil / Matheo Salavin-Moura / Evan Giloppé
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# Programmation WEB coté serveur R3.01
|
||||
Ce dépôt contient les ressources utilisées
|
||||
(cours/td/tp) dans la ressource R3.01.
|
||||
|
||||
**Les objectifs**
|
||||
|
||||
> Savoir développer une application Web côté serveur, en utilisant le langage PHP.
|
||||
|
||||
Les notions suivantes seront abordées :
|
||||
|
||||
- Le langage php
|
||||
On se limitera aux bases du langages. La couche objet sera présenté très succintement.
|
||||
Toute la suite sera illustré avec PHP.
|
||||
|
||||
- Interaction avec le client
|
||||
URL (Uniform Resource Locator), requêtes, formulaires, transmission des paramètres, des données, etc.
|
||||
|
||||
- Applications Web à états
|
||||
Cookies et sessions
|
||||
|
||||
- Organisation de l’accès aux données
|
||||
Bases de données, annuaires, services Web, etc.
|
||||
|
||||
- Introduction à la programmation objet en PHP
|
||||
Introduction au principe MVC
|
||||
|
||||
- Sensibilisation à la sécurité des applications web
|
||||
|
||||
## Calendrier
|
||||
|
||||
| Semaine | Cours | TD/TP |
|
||||
| ------------------ | -------------------------------------------------------- | ------------------ |
|
||||
| 1 | [Bases du langages](./cours/cm_bases_php.pdf) | |
|
||||
| 2 | | [tp1](./tp/tp1) |
|
||||
| 3 | [Intéractions avec le client](./cours/cm_interaction_client_serveur.pdf) | [tp2](./tp/tp2) |
|
||||
| 4 | [PHP/MySQL](./cours/cm_extension_mysqli.pdf) | [tp3](./tp/tp3) |
|
||||
| 5 | [Cookies et sessions](./cours/cm_cookies_sessions.pdf) | [tp3](./tp/tp3) , [tp4](./tp/tp4) |
|
||||
| 6 | [PHP Objet](./cours/cm_objet.pdf), [MVC avec codeigniter](./cours/cm_mvc.pdf) | [tp5](./tp/tp5) |
|
||||
|
||||
|
||||
|
||||
## Les TPS
|
||||
|
||||
#### TP1 : Bases du langage PHP
|
||||
Le [tp1](./tp/tp1)
|
||||
permet de se familiariser avec le langage PHP.
|
||||
À chaque exercice correspond un sous répertoire avec
|
||||
des fichiers à compléter.
|
||||
|
||||
#### TP2 : Intéractions avec le client, formulaires et PHP
|
||||
Le [tp2](./tp/tp2)
|
||||
aborde la récupération des données de formulaires avec PHP.
|
||||
À chaque exercice correspond un sous répertoire avec
|
||||
des fichiers à compléter.
|
||||
|
||||
#### TP3 : PHP/Mysql
|
||||
Le [tp3](./tp/tp3)
|
||||
aborde l'interfaçage de php avec mysql, au moyen de l'extention
|
||||
[mysqli](http://php.net/manual/fr/book.mysqli.php) de php.
|
||||
À chaque exercice correspond un sous répertoire avec
|
||||
des fichiers à compléter.
|
||||
|
||||
#### TP4 : Cookies et sessions
|
||||
Le [tp4](./tp/tp4)
|
||||
aborde la notion de cookies et de sessions,et
|
||||
les fonctions php dédiées.
|
||||
À chaque exercice correspond un sous répertoire avec
|
||||
des fichiers à compléter.
|
||||
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
|
||||
# TP1 : bases du langage PHP
|
||||
|
||||
**À l'IUT**
|
||||
|
||||
Le repertoire `public_html` à la racine de votre compte est accessible par http(s) à l'url suivante :
|
||||
|
||||
```
|
||||
http[s]://dwarves.iut-fbleau.fr/~login/
|
||||
```
|
||||
|
||||
**Ailleurs**
|
||||
|
||||
Pour monter ce repertoire dans votre aborescence locale, vous pouvez utiliser le programme `sshfs` :
|
||||
```
|
||||
sshfs login@iut-fbleau.fr:/export/home/info-but25/login repertoire/de/montage/local/
|
||||
```
|
||||
|
||||
Depuis la version 5.4, la commande `php` embarque un serveur web interne :
|
||||
|
||||
```bash
|
||||
php -S localhost:8080 -t repertoire
|
||||
```
|
||||
|
||||
Le repertoire passé en paramètre est la racine du serveur web.
|
||||
|
||||
|
||||
### Ex1
|
||||
Vous allez tester votre premier script php : `hello_world` :
|
||||
```php
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<?php echo "<h1>hello world</h1>";?>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
- Placez le fichier `hello_world.php` dans votre
|
||||
repertoire `public_html`, et testez.
|
||||
|
||||
- En utilisant la fonction `phpinfo`, faites afficher dans le script
|
||||
précédent la configuration php du serveur dwarves.
|
||||
|
||||
### Ex2
|
||||
Quel est l'entier servant de clé à
|
||||
- chaque élément du tableau
|
||||
suivant :
|
||||
```php
|
||||
<?php
|
||||
$clients = [
|
||||
"Luc",
|
||||
7 => "Paul",
|
||||
2 =>"Martin",
|
||||
"Arnaud"
|
||||
];
|
||||
?>
|
||||
```
|
||||
|
||||
- à l'élément de valeur `Blouson` dans le tableau `$produits` ?
|
||||
```php
|
||||
<?php
|
||||
$produits = [
|
||||
20 => "Chemise",
|
||||
3 => "Pantalon",
|
||||
10 => "Jupe",
|
||||
"Veste",
|
||||
"Blouson"
|
||||
];
|
||||
?>
|
||||
```
|
||||
- à chaque élément du tableau `$array` ?
|
||||
```php
|
||||
<?php
|
||||
$array = ["a","b","c"];
|
||||
$array[] = "d";
|
||||
$array[10] = "j";
|
||||
unset($array[2]);
|
||||
?>
|
||||
```
|
||||
### Ex21
|
||||
- Créez un tableau de 10 cases dont la clé i contient la somme des entiers jusqu'à i.
|
||||
- Créez un tableau de 10 cases dont la clé i<sup>2</sup> contient i
|
||||
.
|
||||
### Ex22
|
||||
Écrivez un script php affichant les entiers de 1 à 50.
|
||||
- Faites en sorte que les impairs soient en italique, et les pairs en gras.
|
||||
- Regroupez chaque dizaine dans un même paragraphe.
|
||||
|
||||
### Ex3
|
||||
Vous disposez du fichier [data.php](./ex3/include/data.inc.php) qui
|
||||
représente, sous forme d'un tableau, un certain nombre
|
||||
d'individus, avec pour chacun ses nom, prénom, email, taille et
|
||||
poids.
|
||||
|
||||
Voici un extrait du fichier :
|
||||
```php
|
||||
$data = array(
|
||||
array("Nom"=>"Garza","Prenom"=>"Forrest","Email"=>"eleifend@ligulaedu","Taille"=>"185","Poids"=>"65"),
|
||||
array("Nom"=>"Tanner","Prenom"=>"Orla","Email"=>"adipiscing@vitaecouk","Taille"=>"180","Poids"=>"73"),
|
||||
...
|
||||
```
|
||||
|
||||
1. Ecrire un script qui affichent l'ensemble des données sous
|
||||
forme d'un tableau html.
|
||||
2. L'imc (indice de masse corporel) d'une personne est donné par
|
||||
la formule $\frac{poids}{taille^2}$ (poids en kilogramme et taille en mètre).
|
||||
Ajouter une colonne avec la valeur de l'imc (2 chiffres après la virgule).
|
||||
3. Une personne est considérée en surpoids lorsque son imc
|
||||
dépasse 25. Colorier les lignes du tableau lorsque la
|
||||
personne correspondante est en surpoids.
|
||||

|
||||
|
||||
<details><summary>Conseils</summary>
|
||||
<div>
|
||||
|
||||
- Pour utiliser le fichier de données, incluez-le dans votre
|
||||
script.
|
||||
- La structure de langage `foreach` fournit une façon simple de
|
||||
parcourir des tableaux. `foreach` ne fonctionne que pour les
|
||||
tableaux et les objets, et émettra une erreur si vous tentez de
|
||||
l'utiliser sur une variable de type différent ou une variable
|
||||
non initialisée. Il existe deux syntaxes :
|
||||
|
||||
```php
|
||||
foreach (array_expression as $value){
|
||||
|
||||
}
|
||||
|
||||
foreach (array_expression as $key => $value){
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Des [exemples]](http://fr2.php.net/manual/fr/control-structures.foreach.php).
|
||||
|
||||
- Pour arrondir un réel, vous pouvez utiliser la fonction [round](https://www.php.net/manual/fr/function.round.php).
|
||||
</div>
|
||||
</details>
|
||||
|
||||
### Ex4
|
||||
Ecrivez un script qui permet de lancer deux dés, et en affiche la somme. Utilisez la fonction [mt_rand](https://www.php.net/manual/en/function.mt-rand.php) pour la génération aléatoire.
|
||||
|
||||
|
||||

|
||||
|
||||
### Ex5
|
||||
Ecrire un programme PHP qui affiche, sous forme d'une liste
|
||||
"cliquable" vos bookmarks (favoris) stockés dans un tableau
|
||||
associatif. Vos bookmarks seront classés par répertoire. Chaque
|
||||
répertoire aura donc un nom, et contiendra un certain nombre de
|
||||
favoris représentés par un nom, une image et une url.
|
||||
|
||||
Exemple d'affichage :
|
||||
|
||||
- Moteurs de recherche :
|
||||
- [<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/272px-Google_2015_logo.svg.png" width=40>](http://google.fr).
|
||||
- [<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Yahoo%21_%282019%29.svg/200px-Yahoo%21_%282019%29.svg.png" width=40>](http://yahoo.fr).
|
||||
- Journaux :
|
||||
- [<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Le_monde_logo.svg/200px-Le_monde_logo.svg.png" width=40>](http://lemonde.fr).
|
||||
- [<img src="http://upload.wikimedia.org/wikipedia/fr/0/0a/GNUlinuxmagazinefrance.png" width=40>](http://www.unixgarden.com/index.php/category/gnu-linux-magazine).
|
||||
- [<img src="http://upload.wikimedia.org/wikipedia/commons/3/32/L%27%C3%89quipe_wordmark.svg" width=40>](http://lequipe.fr).
|
||||
- Sports :
|
||||
- [<img src="http://upload.wikimedia.org/wikipedia/fr/6/67/Logo_F%C3%A9d%C3%A9ration_Fran%C3%A7aise_de_Football.svg" width=50>](http://fff.fr).
|
||||
- [<img src="http://upload.wikimedia.org/wikipedia/fr/b/bf/FFDF.jpg" width=50>](www.ffdf.fr).
|
||||
|
||||
### Ex6
|
||||
Ecrire (et tester) une fonction
|
||||
|
||||
```php
|
||||
<?php
|
||||
string createPassword(int $n, string $alphabet);
|
||||
?>
|
||||
```
|
||||
|
||||
qui permet de générer un mot de passe de `n` caractères choisis
|
||||
aléatoirement parmi les caractères de `alphabet`.
|
||||
|
||||
<details><summary>Conseils</summary>
|
||||
|
||||
Il suffit de tirer aléatoirement n caractères de la chaîne alphabet et de les concatener.
|
||||
|
||||
Les fonctions
|
||||
[strlen](https://www.php.net/manual/fr/function.strlen.php)
|
||||
et
|
||||
[mt_rand](https://www.php.net/manual/fr/function.mt-rand.php) pourront vous être utiles.
|
||||
</details>
|
||||
|
||||
### Ex61
|
||||
On considère les deux tableaux suivants :
|
||||
|
||||
```php
|
||||
$tabMagazines = [
|
||||
'le monde' => ['frequence' => 'quotidien', 'type' => 'actualité', 'prix' => 220],
|
||||
'le point' => ['frequence' => 'hebdo' , 'type' => 'actualité', 'prix' => 80 ],
|
||||
'causette' => ['frequence' => 'mensuel' , 'type' => 'féminin' , 'prix' => 180],
|
||||
'politis' => ['frequence' => 'hebdo' , 'type' => 'opinion' , 'prix' => 100],
|
||||
'le monde diplomatique' => ['frequence' => 'mensuel' , 'type' => 'analyse' , 'prix' => 60 ],
|
||||
'libération' => ['frequence' => 'quotidien', 'type' => 'actualité', 'prix' => 190],
|
||||
];
|
||||
|
||||
$tabMagazinesAbonne = ['le monde', 'le monde diplomatique'];
|
||||
```
|
||||
|
||||
|
||||
1. Afficher sur une ligne le nom de tous les magazines triés par ordre alphabétique et séparés par des virgules, sans faire de boucle.
|
||||
Vous utiliserez des fonctions déjà existantes telles que [implode](https://www.php.net/manual/en/function.implode.php), [sort](https://www.php.net/manual/en/function.sort.php) et [array_keys](https://www.php.net/manual/en/function.array-keys.php) que vous trouverez dans le manuel php.
|
||||
2. Afficher séparés par des virgule les noms des quotidiens (et uniquement ceux-ci).
|
||||
3. Afficher les magazines exactement de la façon suivante en supposant qu’il peut y avoir beaucoup de magazines et beaucoup de propriétés associées :
|
||||
- le monde (quotidien, actualité, 220)
|
||||
- le point (hebdo, actualité, 80)
|
||||
- causette (mensuel, féministe, 180)
|
||||
- politis (hebdo, opinion, 100)
|
||||
- le monde diplomatique (mensuel, analyse, 60)
|
||||
4. En utilisant le tableau `$tabMagazinesAbonne` contenant le nom des magazines d’un abonné, calculer le prix total de son abonnement.
|
||||
|
||||
### Ex62
|
||||
Sur les anciens cahiers d'écoliers, on trouvait sur la courveture la liste des tables de multiplications
|
||||
<div align="center">
|
||||
<img src="img/cahier.jpg">
|
||||
</div>
|
||||
|
||||
Écrire un script php qui affiche les tables correspondantes.
|
||||
|
||||
### Ex7
|
||||
On reprend l'exercice 3.
|
||||
|
||||
1. Ajouter une colonne de clé `Imc` aux personnes du tableau `$data`. On utilisera la fonction
|
||||
[array_map](https://www.php.net/manual/fr/function.array-map.php).
|
||||
2. Trier `$data` par ordre croissant d'imc. On utilisera la fonction [usort](https://www.php.net/manual/fr/function.usort.php).
|
||||
3. Calculer l'imc moyen de l'ensemble des personnes. On utilisera la fonction [array_reduce](https://www.php.net/manual/fr/function.array-reduce.php).
|
||||
|
||||
|
||||
### Ex8
|
||||
1. Allez voir la page manuel PHP de [scandir](https://www.php.net/manual/en/function.scandir).
|
||||
Quel(s) sont ses arguments ? Que renvoie-t-elle ?
|
||||
2. Utilisez scandir pour afficher des liens vers les autres fichiers de votre dossier public_html. On rappelle
|
||||
que la balise html `a` permet de créer des hyperliens.
|
||||
3. Utilisez la méthode [str_ends_with](https://www.php.net/manual/en/function.str-ends-with.php) pour n’afficher que les scripts PHP.
|
||||
|
||||
Par ailleurs, une liste des fonctions sur les chaînes de caractères est disponible [ici](https://www.php.net/ref.strings).
|
||||
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<?php
|
||||
echo "<h1>hello world !!!</h1>";
|
||||
phpinfo();
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
$clients = [
|
||||
"Luc",
|
||||
7 => "Paul",
|
||||
2 =>"Martin",
|
||||
"Arnaud"
|
||||
];
|
||||
|
||||
var_dump($clients);
|
||||
|
||||
$produits = [
|
||||
20 => "Chemise",
|
||||
3 => "Pantalon",
|
||||
10 => "Jupe",
|
||||
"Veste",
|
||||
"Blouson"
|
||||
];
|
||||
$array = ["a","b","c"];
|
||||
$array[] = "d";
|
||||
$array[10] = "j";
|
||||
unset($array[2]);
|
||||
|
||||
echo "<pre>";
|
||||
print_r($clients);
|
||||
print_r($produits);
|
||||
print_r($array);
|
||||
echo "</pre>";
|
||||
|
||||
// Exercice 2.1
|
||||
$tab = [];
|
||||
$somme = 0;
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$somme += $i; // somme des entiers de 0 à i
|
||||
$tab[$i] = $somme; // la clé i contient cette somme
|
||||
}
|
||||
print_r($tab);
|
||||
|
||||
|
||||
// Exercice 2.2
|
||||
for ($debut = 1; $debut <= 50; $debut += 10) {
|
||||
echo "<p>";
|
||||
for ($i = $debut; $i < $debut + 10; $i++) {
|
||||
if ($i % 2 === 0) {
|
||||
echo "<strong>$i</strong> ";
|
||||
} else {
|
||||
echo "<em>$i</em> ";
|
||||
}
|
||||
}
|
||||
echo "</p>";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,3 @@
|
||||
.warning tr,.warning td {
|
||||
background-color : rgb(255,154,0);
|
||||
}
|
||||
|
After Width: | Height: | Size: 114 KiB |
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
$data = array(
|
||||
array("Nom"=>"Garza","Prenom"=>"Forrest","Email"=>"eleifend@ligulaedu","Taille"=>"185","Poids"=>"65"),
|
||||
array("Nom"=>"Tanner","Prenom"=>"Orla","Email"=>"adipiscing@vitaecouk","Taille"=>"180","Poids"=>"73"),
|
||||
array("Nom"=>"Griffith","Prenom"=>"Susan","Email"=>"condimentum@tristiqueca","Taille"=>"172","Poids"=>"75"),
|
||||
array("Nom"=>"Wilkinson","Prenom"=>"Carla","Email"=>"tinciduntaliquamarcu@utmolestieca","Taille"=>"178","Poids"=>"71"),
|
||||
array("Nom"=>"Kirkland","Prenom"=>"Vladimir","Email"=>"Donec@egettinciduntduiorg","Taille"=>"178","Poids"=>"73"),
|
||||
array("Nom"=>"Holloway","Prenom"=>"Joy","Email"=>"enim@Nullamca","Taille"=>"191","Poids"=>"67"),
|
||||
array("Nom"=>"Soto","Prenom"=>"Cleo","Email"=>"posuereatvelit@Incondimentumca","Taille"=>"167","Poids"=>"70"),
|
||||
array("Nom"=>"Jacobson","Prenom"=>"Linda","Email"=>"disparturientmontes@metusurnaconvallisnet","Taille"=>"169","Poids"=>"73"),
|
||||
array("Nom"=>"Wilder","Prenom"=>"Ina","Email"=>"odiovel@eratcouk","Taille"=>"167","Poids"=>"68"),
|
||||
array("Nom"=>"Pace","Prenom"=>"Melvin","Email"=>"euismodindolor@DonecestNuncca","Taille"=>"175","Poids"=>"68"),
|
||||
array("Nom"=>"Moody","Prenom"=>"Hayden","Email"=>"ornareelit@malesuadaIntegeridedu","Taille"=>"180","Poids"=>"63"),
|
||||
array("Nom"=>"Rhodes","Prenom"=>"Jarrod","Email"=>"turpis@placeratnet","Taille"=>"168","Poids"=>"68"),
|
||||
array("Nom"=>"Bean","Prenom"=>"Marah","Email"=>"suscipitest@ullamcorperDuiscursusnet","Taille"=>"165","Poids"=>"61"),
|
||||
array("Nom"=>"Beard","Prenom"=>"Dylan","Email"=>"nonmagna@mollisnet","Taille"=>"173","Poids"=>"62"),
|
||||
array("Nom"=>"Davenport","Prenom"=>"September","Email"=>"amet@purusca","Taille"=>"179","Poids"=>"67"),
|
||||
array("Nom"=>"Boyd","Prenom"=>"Natalie","Email"=>"Aeneangravidanunc@metusorg","Taille"=>"179","Poids"=>"62"),
|
||||
array("Nom"=>"Davidson","Prenom"=>"Kane","Email"=>"ullamcorpermagnaSed@eutemporcouk","Taille"=>"181","Poids"=>"67"),
|
||||
array("Nom"=>"Burch","Prenom"=>"Tanek","Email"=>"a@Vivamussitorg","Taille"=>"169","Poids"=>"69"),
|
||||
array("Nom"=>"Talley","Prenom"=>"Leo","Email"=>"musAeneaneget@ornareliberoatcom","Taille"=>"167","Poids"=>"72"),
|
||||
array("Nom"=>"Stephens","Prenom"=>"Simone","Email"=>"in@auctorodioacom","Taille"=>"170","Poids"=>"65"),
|
||||
array("Nom"=>"Haynes","Prenom"=>"Gloria","Email"=>"liberoettristique@diamvelarcucouk","Taille"=>"169","Poids"=>"70"),
|
||||
array("Nom"=>"Blanchard","Prenom"=>"Faith","Email"=>"massa@augueeutellusnet","Taille"=>"166","Poids"=>"62"),
|
||||
array("Nom"=>"Randall","Prenom"=>"Blaze","Email"=>"atpede@blanditNamnullacom","Taille"=>"163","Poids"=>"66"),
|
||||
array("Nom"=>"Griffith","Prenom"=>"Roary","Email"=>"aliquetmetus@velnislcouk","Taille"=>"162","Poids"=>"64"),
|
||||
array("Nom"=>"Morgan","Prenom"=>"Tanner","Email"=>"egetlaoreet@arcucouk","Taille"=>"179","Poids"=>"67"),
|
||||
array("Nom"=>"Chapman","Prenom"=>"Amelia","Email"=>"nunc@massaQuisquecom","Taille"=>"164","Poids"=>"69"),
|
||||
array("Nom"=>"Grant","Prenom"=>"Chloe","Email"=>"auctorMauris@loremegetorg","Taille"=>"173","Poids"=>"72"),
|
||||
array("Nom"=>"Richardson","Prenom"=>"Ryan","Email"=>"scelerisque@ullamcorpermagnacouk","Taille"=>"173","Poids"=>"64"),
|
||||
array("Nom"=>"Cleveland","Prenom"=>"Yeo","Email"=>"acsem@vehiculaca","Taille"=>"163","Poids"=>"69"),
|
||||
array("Nom"=>"Gay","Prenom"=>"Amanda","Email"=>"fames@idsapienedu","Taille"=>"165","Poids"=>"63"),
|
||||
array("Nom"=>"Peters","Prenom"=>"Bruno","Email"=>"ornaretortor@condimentumDonecatcom","Taille"=>"163","Poids"=>"66"),
|
||||
array("Nom"=>"Lambert","Prenom"=>"Dean","Email"=>"sapien@sitametrisuscouk","Taille"=>"180","Poids"=>"71"),
|
||||
array("Nom"=>"Petty","Prenom"=>"Nigel","Email"=>"pedeSuspendisse@risusDuiscouk","Taille"=>"168","Poids"=>"66"),
|
||||
array("Nom"=>"Phelps","Prenom"=>"Cullen","Email"=>"euaugue@Vestibulumanteca","Taille"=>"159","Poids"=>"76"),
|
||||
array("Nom"=>"Cochran","Prenom"=>"Marny","Email"=>"Lorem@enimconsequatpuruscouk","Taille"=>"157","Poids"=>"67"),
|
||||
array("Nom"=>"Bauer","Prenom"=>"Sloane","Email"=>"nisi@liberonet","Taille"=>"174","Poids"=>"72"),
|
||||
array("Nom"=>"Strong","Prenom"=>"Leigh","Email"=>"ut@Aliquamcouk","Taille"=>"176","Poids"=>"65"),
|
||||
array("Nom"=>"Olsen","Prenom"=>"Herrod","Email"=>"uteratSed@rutrumloremedu","Taille"=>"167","Poids"=>"72"),
|
||||
array("Nom"=>"Spears","Prenom"=>"Bruno","Email"=>"congueturpis@nullaorg","Taille"=>"162","Poids"=>"77"),
|
||||
array("Nom"=>"Pearson","Prenom"=>"Marah","Email"=>"Donecatarcu@aedu","Taille"=>"174","Poids"=>"62"),
|
||||
array("Nom"=>"Moore","Prenom"=>"Orson","Email"=>"semegetmassa@puruscouk","Taille"=>"189","Poids"=>"76"),
|
||||
array("Nom"=>"Roman","Prenom"=>"Kylie","Email"=>"habitant@duiaugueca","Taille"=>"177","Poids"=>"66"),
|
||||
array("Nom"=>"Michael","Prenom"=>"Ciaran","Email"=>"nostraper@nibhPhaselluscom","Taille"=>"156","Poids"=>"65"),
|
||||
array("Nom"=>"Sheppard","Prenom"=>"Colton","Email"=>"enim@inaliquetedu","Taille"=>"159","Poids"=>"70"),
|
||||
array("Nom"=>"Mathews","Prenom"=>"Pamela","Email"=>"auctor@Praesenteuedu","Taille"=>"168","Poids"=>"74"),
|
||||
array("Nom"=>"Thompson","Prenom"=>"Olga","Email"=>"vel@egestascom","Taille"=>"173","Poids"=>"75"),
|
||||
array("Nom"=>"Petersen","Prenom"=>"Jared","Email"=>"urna@Crasvulputatevelitca","Taille"=>"173","Poids"=>"75"),
|
||||
array("Nom"=>"Leblanc","Prenom"=>"Aurora","Email"=>"dictum@egetcom","Taille"=>"164","Poids"=>"72"),
|
||||
array("Nom"=>"Blanchard","Prenom"=>"Keiko","Email"=>"Suspendisse@torquentperconubiacouk","Taille"=>"167","Poids"=>"72"),
|
||||
array("Nom"=>"Sharp","Prenom"=>"Barrett","Email"=>"Proineget@laoreetposuereedu","Taille"=>"163","Poids"=>"72"),
|
||||
array("Nom"=>"Hughes","Prenom"=>"Orson","Email"=>"utdolor@risusDonecegestasnet","Taille"=>"159","Poids"=>"62"),
|
||||
array("Nom"=>"Porter","Prenom"=>"Ava","Email"=>"Fuscedolor@Nuncnet","Taille"=>"178","Poids"=>"70"),
|
||||
array("Nom"=>"Figueroa","Prenom"=>"Lesley","Email"=>"Quisquenonummy@eulacusorg","Taille"=>"168","Poids"=>"68"),
|
||||
array("Nom"=>"Wyatt","Prenom"=>"Zelenia","Email"=>"sitametultricies@accumsansedfacilisiscom","Taille"=>"174","Poids"=>"61"),
|
||||
array("Nom"=>"Stark","Prenom"=>"Sarah","Email"=>"natoquepenatibuset@neccursusacom","Taille"=>"167","Poids"=>"67"),
|
||||
array("Nom"=>"Carney","Prenom"=>"Ariana","Email"=>"enimsit@nuncinterdumfeugiatorg","Taille"=>"180","Poids"=>"78"),
|
||||
array("Nom"=>"Simmons","Prenom"=>"Herrod","Email"=>"ac@estnet","Taille"=>"172","Poids"=>"72"),
|
||||
array("Nom"=>"Mayo","Prenom"=>"Carissa","Email"=>"Nulla@quamquisca","Taille"=>"182","Poids"=>"60"),
|
||||
array("Nom"=>"Higgins","Prenom"=>"Serena","Email"=>"anteblanditviverra@aliquetPhasellusfermentumedu","Taille"=>"178","Poids"=>"71"),
|
||||
array("Nom"=>"Fletcher","Prenom"=>"Remedios","Email"=>"Phaselluselitpede@consequatcouk","Taille"=>"180","Poids"=>"73"),
|
||||
array("Nom"=>"Green","Prenom"=>"Dale","Email"=>"libero@temporeratorg","Taille"=>"171","Poids"=>"68"),
|
||||
array("Nom"=>"White","Prenom"=>"Jack","Email"=>"velconvallis@anteedu","Taille"=>"172","Poids"=>"73"),
|
||||
array("Nom"=>"Russo","Prenom"=>"Giselle","Email"=>"nonnisi@luctusvulputateorg","Taille"=>"160","Poids"=>"69"),
|
||||
array("Nom"=>"James","Prenom"=>"Kimberley","Email"=>"malesuadafamesac@nuncsitametcom","Taille"=>"191","Poids"=>"72"),
|
||||
array("Nom"=>"Huffman","Prenom"=>"Thomas","Email"=>"Nuncmauriselit@Pellentesqueca","Taille"=>"168","Poids"=>"68"),
|
||||
array("Nom"=>"Turner","Prenom"=>"Cody","Email"=>"lorem@elitcouk","Taille"=>"172","Poids"=>"73"),
|
||||
array("Nom"=>"Neal","Prenom"=>"Cheryl","Email"=>"nequevitaesemper@rhoncusidcom","Taille"=>"170","Poids"=>"68"),
|
||||
array("Nom"=>"Patel","Prenom"=>"Hamilton","Email"=>"ametultriciessem@nonantebibendumedu","Taille"=>"172","Poids"=>"79"),
|
||||
array("Nom"=>"Alexander","Prenom"=>"Grant","Email"=>"nonnisiAenean@massacom","Taille"=>"174","Poids"=>"68"),
|
||||
array("Nom"=>"Shepherd","Prenom"=>"Tad","Email"=>"ac@inorg","Taille"=>"165","Poids"=>"76"),
|
||||
array("Nom"=>"Wynn","Prenom"=>"Danielle","Email"=>"lectusquismassa@InfaucibusMorbiorg","Taille"=>"169","Poids"=>"66"),
|
||||
array("Nom"=>"Pollard","Prenom"=>"Ahmed","Email"=>"velarcu@Nullaegetorg","Taille"=>"164","Poids"=>"62"),
|
||||
array("Nom"=>"Peters","Prenom"=>"Hollee","Email"=>"loremipsum@sitametca","Taille"=>"177","Poids"=>"75"),
|
||||
array("Nom"=>"Alston","Prenom"=>"Brendan","Email"=>"antebibendumullamcorper@idblanditcouk","Taille"=>"156","Poids"=>"68"),
|
||||
array("Nom"=>"Keith","Prenom"=>"Vernon","Email"=>"diam@sagittisnet","Taille"=>"168","Poids"=>"70"),
|
||||
array("Nom"=>"Rodgers","Prenom"=>"Angela","Email"=>"pharetra@vellectusCumcom","Taille"=>"171","Poids"=>"65"),
|
||||
array("Nom"=>"Parker","Prenom"=>"Tatiana","Email"=>"penatibusetmagnis@scelerisquesedca","Taille"=>"173","Poids"=>"68"),
|
||||
array("Nom"=>"Miller","Prenom"=>"Timothy","Email"=>"tinciduntcongue@atca","Taille"=>"178","Poids"=>"66"),
|
||||
array("Nom"=>"Wilder","Prenom"=>"Rosalyn","Email"=>"mauris@aliquameuorg","Taille"=>"165","Poids"=>"67"),
|
||||
array("Nom"=>"Baker","Prenom"=>"Sheila","Email"=>"sitametrisus@euplacerategetcouk","Taille"=>"178","Poids"=>"69"),
|
||||
array("Nom"=>"Lee","Prenom"=>"Roary","Email"=>"nequenon@acouk","Taille"=>"159","Poids"=>"61"),
|
||||
array("Nom"=>"Gillespie","Prenom"=>"Quemby","Email"=>"nonenimcommodo@lobortiscom","Taille"=>"167","Poids"=>"61"),
|
||||
array("Nom"=>"Dixon","Prenom"=>"Zenaida","Email"=>"risus@etmagnisdisca","Taille"=>"170","Poids"=>"72"),
|
||||
array("Nom"=>"Holden","Prenom"=>"Chloe","Email"=>"in@elementumorg","Taille"=>"169","Poids"=>"76"),
|
||||
array("Nom"=>"Rios","Prenom"=>"Stone","Email"=>"consequatenim@enimMaurisca","Taille"=>"169","Poids"=>"77"),
|
||||
array("Nom"=>"Berg","Prenom"=>"Sara","Email"=>"faucibusleo@Maurisblanditenimorg","Taille"=>"162","Poids"=>"63"),
|
||||
array("Nom"=>"Clay","Prenom"=>"Timon","Email"=>"etultrices@necorg","Taille"=>"168","Poids"=>"72"),
|
||||
array("Nom"=>"Schneider","Prenom"=>"Knox","Email"=>"dolor@liberoca","Taille"=>"165","Poids"=>"65"),
|
||||
array("Nom"=>"Cervantes","Prenom"=>"Pandora","Email"=>"metusVivamuseuismod@ligulaca","Taille"=>"179","Poids"=>"73"),
|
||||
array("Nom"=>"Allen","Prenom"=>"Micah","Email"=>"dolorsitamet@nonhendreritorg","Taille"=>"176","Poids"=>"75"),
|
||||
array("Nom"=>"Kirkland","Prenom"=>"Jolie","Email"=>"Fuscemollis@Nuncullamcorperorg","Taille"=>"154","Poids"=>"66"),
|
||||
array("Nom"=>"Woodard","Prenom"=>"Quincy","Email"=>"idliberoDonec@Phasellusnullaca","Taille"=>"166","Poids"=>"69"),
|
||||
array("Nom"=>"Peck","Prenom"=>"Octavius","Email"=>"lobortis@semperegestasurnaca","Taille"=>"167","Poids"=>"68"),
|
||||
array("Nom"=>"Andrews","Prenom"=>"Wade","Email"=>"sedpede@mifelisorg","Taille"=>"158","Poids"=>"64"),
|
||||
array("Nom"=>"Kennedy","Prenom"=>"Lydia","Email"=>"Vestibulumaccumsanneque@ipsumnuncidnet","Taille"=>"178","Poids"=>"67"),
|
||||
array("Nom"=>"Velez","Prenom"=>"Erin","Email"=>"sagittisDuisgravida@nonduineccouk","Taille"=>"167","Poids"=>"66"),
|
||||
array("Nom"=>"Hendrix","Prenom"=>"Sopoline","Email"=>"asollicitudin@etcouk","Taille"=>"173","Poids"=>"74"),
|
||||
array("Nom"=>"Boyd","Prenom"=>"Neville","Email"=>"nuncidenim@vehiculaPellentesquetinciduntcom","Taille"=>"173","Poids"=>"75"),
|
||||
array("Nom"=>"Rice","Prenom"=>"Lois","Email"=>"nonmassanon@Aeneanca","Taille"=>"166","Poids"=>"58"),
|
||||
array("Nom"=>"Lloyd","Prenom"=>"Aline","Email"=>"dapibusgravida@utmolestieinedu","Taille"=>"145","Poids"=>"80")
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
include_once './include/data.inc.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>tp1 - ex3</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h2>Exercice 3 : IMC </h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Prénom</th>
|
||||
<th>Email</th>
|
||||
<th>Taille</th>
|
||||
<th>Poids</th>
|
||||
<th>IMC</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php include_once './include/data.inc.php'; ?>
|
||||
<?php foreach ($data as $person) : ?>
|
||||
<?php
|
||||
$poids = (float) $person['Poids'];
|
||||
$tailleM = (float) $person['Taille'] / 100;
|
||||
|
||||
$imc = null;
|
||||
if ($tailleM > 0) {
|
||||
$imc = $poids / ($tailleM * $tailleM);
|
||||
}
|
||||
?>
|
||||
<tr class="<?= $imc < 18.5 ? 'underweight' : ($imc < 25 ? 'normal' : 'warning') ?>">
|
||||
<td><?= $person['Nom'] ?></td>
|
||||
<td><?= $person['Prenom'] ?></td>
|
||||
<td><?= $person['Email'] ?></td>
|
||||
<td><?= $person['Taille'] ?></td>
|
||||
<td><?= $person['Poids'] ?></td>
|
||||
<td><?= round($imc, 2) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
img{
|
||||
width : 10rem;
|
||||
margin:2rem;
|
||||
}
|
||||
.is-center{
|
||||
text-align : center;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0h512v512h-512z"/>
|
||||
<path d="m74.5,36h363a38.5,38.5 0 0,1 38.5,38.5v363a38.5,38.5 0 0,1 -38.5,38.5h-363a38.5,38.5 0 0,1 -38.5-38.5v-363a38.5,38.5 0 0,1 38.5-38.5" fill="#fff"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(0,-.71549,.71911,0,123.67678,212.03015)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,254.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,522.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,522.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,254.32322)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1020 B |
@@ -0,0 +1,8 @@
|
||||
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0h512v512h-512z"/>
|
||||
<path d="m74.5,36h363a38.5,38.5 0 0,1 38.5,38.5v363a38.5,38.5 0 0,1 -38.5,38.5h-363a38.5,38.5 0 0,1 -38.5-38.5v-363a38.5,38.5 0 0,1 38.5-38.5" fill="#fff"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,254.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,522.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,522.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,254.32322)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 868 B |
@@ -0,0 +1,5 @@
|
||||
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0h512v512h-512z"/>
|
||||
<path d="m74.5,36h363a38.5,38.5 0 0,1 38.5,38.5v363a38.5,38.5 0 0,1 -38.5,38.5h-363a38.5,38.5 0 0,1 -38.5-38.5v-363a38.5,38.5 0 0,1 38.5-38.5" fill="#fff"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(0,-.71549,.71911,0,123.67678,212.03015)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 410 B |
@@ -0,0 +1,10 @@
|
||||
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0h512v512h-512z"/>
|
||||
<path d="m74.5,36h363a38.5,38.5 0 0,1 38.5,38.5v363a38.5,38.5 0 0,1 -38.5,38.5h-363a38.5,38.5 0 0,1 -38.5-38.5v-363a38.5,38.5 0 0,1 38.5-38.5" fill="#fff"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(0,-.71549,.71911,0,257.67678,212.03015)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(0,-.71549,.71911,0,-10.32322,212.03015)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,254.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,522.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,522.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,254.32322)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,7 @@
|
||||
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0h512v512h-512z"/>
|
||||
<path d="m74.5,36h363a38.5,38.5 0 0,1 38.5,38.5v363a38.5,38.5 0 0,1 -38.5,38.5h-363a38.5,38.5 0 0,1 -38.5-38.5v-363a38.5,38.5 0 0,1 38.5-38.5" fill="#fff"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(0,-.71549,.71911,0,123.67678,212.03015)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,254.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,522.32322)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 715 B |
@@ -0,0 +1,6 @@
|
||||
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0h512v512h-512z"/>
|
||||
<path d="m74.5,36h363a38.5,38.5 0 0,1 38.5,38.5v363a38.5,38.5 0 0,1 -38.5,38.5h-363a38.5,38.5 0 0,1 -38.5-38.5v-363a38.5,38.5 0 0,1 38.5-38.5" fill="#fff"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,346.03015,254.32322)"/>
|
||||
<path d="m8.428,184.011a69.882,69.5309 0 1,1 -139.7641,0 69.882,69.5309 0 1,1 139.7641,0z" transform="matrix(-.71549,0,0,-.71911,78.03015,522.32322)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 563 B |
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// Generate random values for two six-sided dice.
|
||||
$die1 = mt_rand(1, 6);
|
||||
$die2 = mt_rand(1, 6);
|
||||
$sum = $die1 + $die2;
|
||||
|
||||
// Map dice values to matching SVG filenames.
|
||||
$diceImages = [
|
||||
1 => 'dice-six-faces-one.svg',
|
||||
2 => 'dice-six-faces-two.svg',
|
||||
3 => 'dice-six-faces-three.svg',
|
||||
4 => 'dice-six-faces-four.svg',
|
||||
5 => 'dice-six-faces-five.svg',
|
||||
6 => 'dice-six-faces-six.svg',
|
||||
];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>tp1 - ex4</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h5><a href="./">Tirage aléatoire</a></h5>
|
||||
<article class="is-center">
|
||||
<img src="./img/<?= $diceImages[$die1] ?>" alt="Dé 1 : <?= $die1 ?>">
|
||||
<img src="./img/<?= $diceImages[$die2] ?>" alt="Dé 2 : <?= $die2 ?>">
|
||||
</article>
|
||||
<h5>Somme = <?= $sum ?></h5>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,5 @@
|
||||
img{
|
||||
height:15px;
|
||||
vertical-align:middle;
|
||||
margin:0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
$favoris = [
|
||||
"Moteurs de recherche" => [
|
||||
[
|
||||
"nom"=>"Google",
|
||||
"url"=>"http://google.com",
|
||||
"img"=>"https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/272px-Google_2015_logo.svg.png"
|
||||
],
|
||||
[
|
||||
"nom"=>"Yahoo",
|
||||
"url"=>"http://yahoo.com",
|
||||
"img"=>"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Yahoo%21_%282019%29.svg/200px-Yahoo%21_%282019%29.svg.png"
|
||||
]
|
||||
],
|
||||
"Journaux" => [
|
||||
[
|
||||
"nom"=>"Le Monde",
|
||||
"url"=>"http://lemonde.fr",
|
||||
"img"=>"http://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Le_monde_logo.svg/200px-Le_monde_logo.svg.png"
|
||||
],
|
||||
[
|
||||
"nom"=>"L'equipe",
|
||||
"url"=>"http://lequipe.fr",
|
||||
"img"=>"http://upload.wikimedia.org/wikipedia/commons/3/32/L%27%C3%89quipe_wordmark.svg"
|
||||
]
|
||||
]
|
||||
];
|
||||
?>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include_once './include/favoris.inc.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>tp1 - ex4</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h2>
|
||||
Exercice 4 : Favoris
|
||||
</h2>
|
||||
|
||||
<!-- À compléter -->
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
function createPassword($n,$alphabet) {
|
||||
$length = strlen($alphabet);
|
||||
$password = "";
|
||||
return $password;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
include_once './include/fonction.php';
|
||||
$alphabet = "@#!*^&azertyuiopqsdfghjkklmwxcvbnAZERTYUIOPLMKJHGFDSQWXCVBN1234567890";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Exercice 5</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<hgroup>
|
||||
<h2>Exercice 5 : createPassword </h2>
|
||||
<h3>
|
||||
Test de la fonction createPassword
|
||||
</h3>
|
||||
</hgroup>
|
||||
<article>
|
||||
<ul>
|
||||
<li><code><?php echo createPassword(5, $alphabet);?></code></li>
|
||||
<li><code><?php echo createPassword(10,$alphabet);?></code></li>
|
||||
<li><code><?php echo createPassword(15,$alphabet);?></code></li>
|
||||
</ul>
|
||||
</article>
|
||||
</main>
|
||||
</body>
|
||||
</main>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 78 KiB |
@@ -0,0 +1,118 @@
|
||||
# TP 2 : Intéractions avec le client. Formulaires HTML et PHP.
|
||||
|
||||
|
||||
|
||||
> On utilisera autant que possible les fonctions
|
||||
[filter\_input](http://php.net/manual/fr/function.filter-input.php) ou
|
||||
[filter\_var](http://php.net/manual/fr/function.filter-var.php) qui
|
||||
permettent de valider le type (ou nettoyer) des entrées d'un formulaire
|
||||
(entre autre).
|
||||
|
||||
### Ex1.
|
||||
Ecrire le script de traitement associé au formulaire (2 champs texte
|
||||
pour le nom et prénom, quatre boutons radio pour choisir le système) qui
|
||||
affiche les données saisies :
|
||||
|
||||
<div align="center">
|
||||
<img src="./img/exo1.png">
|
||||
<img src="./img/exo11.png">
|
||||
</div>
|
||||
|
||||
Faites en sorte que la première lettre (et elle seule) du prénom et
|
||||
du nom soit en en majuscule.
|
||||
|
||||
Vous pouvez utilisez les fonctions :
|
||||
|
||||
```php
|
||||
string strtolower ( string $string );
|
||||
string ucfirst ( string $str );
|
||||
```
|
||||
|
||||
### Ex2.
|
||||
Ecrire un (seul) script qui saisit dans un champs texte un entier et
|
||||
qui affiche la table de multiplication correspondante lors de la
|
||||
soumission.
|
||||
|
||||
<div align="center">
|
||||
<img src="./img/exo2.png">
|
||||
</div>
|
||||
|
||||
|
||||
### Ex3.
|
||||
Ecrire une petite calculatrice permettant d'effectuer des
|
||||
opérations arithmétiques élémentaires (+,x,-,/) sur deux opérandes.
|
||||
|
||||
<div align="center">
|
||||
<img src="./img/exo3.png">
|
||||
</div>
|
||||
|
||||
1. Première version : affichez un formulaire permettant, dans
|
||||
l'ordre, de saisir la première opérande, puis dans une liste
|
||||
(`SELECT`) l'opération, enfin de saisir la deuxième opérande.
|
||||
Associez à ce formulaire le script effectuant le calcul et
|
||||
affichant le résultat.
|
||||
2. Assurez-vous qu'on ne puisse pas diviser par 0.
|
||||
3. Deuxième version : après un calcul, réaffichez le formulaire en
|
||||
proposant comme valeur par défaut de la première opérande le
|
||||
résultat du calcul précédent.
|
||||
|
||||
### Ex4.
|
||||
Vous diposez du fichier html `quizz.html`. Pour chaque question, il
|
||||
n'y a qu'une réponse exacte. On vous demande d'écrire le script
|
||||
php de traitement des réponses qui affiche au joueur le résultat du
|
||||
jeu :
|
||||
|
||||
<div align="center">
|
||||
<img src="./img/exo4.png">
|
||||
<img src="./img/exo41.png">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Regardez-bien comment est structuré le quizz (nom des variables,
|
||||
valeurs transmises, etc ). Cela doit vous permettre d'écrire un
|
||||
script php qui s'adaptera automatiquement si on rajoute ou on
|
||||
enlève des questions au quizz.
|
||||
|
||||
Evidemment, il est très facile de tricher !
|
||||
|
||||
### Ex5.
|
||||
Vous disposez du formulaire suivant :
|
||||
|
||||
<div align="center">
|
||||
<img src="./img/exo5.png">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
- Un champ texte permet de saisir un verbe du premier groupe à
|
||||
conjuguer.
|
||||
- Des cases à cocher permettent de choisir les temps de
|
||||
conjugaisons.
|
||||
|
||||
Ecrire le script PHP qui receptionne les données **postées** par le
|
||||
formulaire précédent, et qui affiche le verbe conjugué aux temps
|
||||
choisis.
|
||||
|
||||
<div align="center">
|
||||
<img src="./img/exo51.png">
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary>Conseils</summary>
|
||||
<div>
|
||||
Pour extraire le radical, vous pouvez utiliser la
|
||||
fonction <a href='http://fr2.php.net/manual/fr/function.substr.php'>substr</a>
|
||||
|
||||
```php
|
||||
string substr ( string $string , int $start [, int $length ] );
|
||||
```
|
||||
|
||||
Vous pouvez également stocker dans un tableau associatif les
|
||||
terminaisons possibles, ainsi que les pronoms personnels.
|
||||
|
||||
```php
|
||||
$terminaisons = array("present"=>array("e","es","e","ons","ez","ent"), ...
|
||||
```
|
||||
</div>
|
||||
</details>
|
||||
@@ -0,0 +1,3 @@
|
||||
form button{
|
||||
float:right;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
<title>Exercice 1</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h3> Exercice 1</h3>
|
||||
|
||||
<form action="ex1.php" method="POST">
|
||||
<fieldset>
|
||||
<legend>Qui êtes-vous ?</legend>
|
||||
<!-- Text input-->
|
||||
<label>Nom
|
||||
<input name="nom" placeholder="nom" type="text">
|
||||
</label>
|
||||
<!-- Text input-->
|
||||
<label >Prénom
|
||||
<input name="prenom" placeholder="prénom" type="text">
|
||||
</label>
|
||||
</fieldset>
|
||||
<!-- Multiple Radios -->
|
||||
<fieldset>
|
||||
<legend>Système d'exploitation préféré</legend>
|
||||
<label>
|
||||
<input name="os" value="1" checked="checked" type="radio">
|
||||
Linux
|
||||
</label>
|
||||
<label >
|
||||
<input name="os" value="2" type="radio">
|
||||
Windows
|
||||
</label>
|
||||
<label >
|
||||
<input name="os" value="3" type="radio">
|
||||
macOS
|
||||
</label>
|
||||
<label >
|
||||
<input name="os" value="4" type="radio">
|
||||
Android
|
||||
</label>
|
||||
</fieldset>
|
||||
<!-- Button -->
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include_once 'include/controller.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Exercice 1</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<ul>
|
||||
<?php
|
||||
echo '<li>' . htmlspecialchars($prenom . ' ' . $nom, ENT_QUOTES, 'UTF-8') . '</li>';
|
||||
echo '<li>' . htmlspecialchars($systeme, ENT_QUOTES, 'UTF-8') . " <i class='fa-brands $icon fa-2x'></i></li>";
|
||||
?>
|
||||
</ul>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
$nom = '';
|
||||
$prenom = '';
|
||||
$systeme = '';
|
||||
$icon = 'fa-circle-question';
|
||||
|
||||
$systemes = [
|
||||
1 => ['nom' => 'Linux', 'icon' => 'fa-linux'],
|
||||
2 => ['nom' => 'Windows', 'icon' => 'fa-windows'],
|
||||
3 => ['nom' => 'macOS', 'icon' => 'fa-apple'],
|
||||
4 => ['nom' => 'Android', 'icon' => 'fa-android'],
|
||||
];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$nomSaisi = trim((string) filter_input(INPUT_POST, 'nom', FILTER_UNSAFE_RAW));
|
||||
$prenomSaisi = trim((string) filter_input(INPUT_POST, 'prenom', FILTER_UNSAFE_RAW));
|
||||
$os = filter_input(INPUT_POST, 'os', FILTER_VALIDATE_INT);
|
||||
|
||||
$nom = ucfirst(strtolower($nomSaisi));
|
||||
$prenom = ucfirst(strtolower($prenomSaisi));
|
||||
|
||||
if (isset($systemes[$os])) {
|
||||
$systeme = $systemes[$os]['nom'];
|
||||
$icon = $systemes[$os]['icon'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
input[type="text"]{
|
||||
display:inline;
|
||||
width:auto;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
$table = filter_input(INPUT_GET, 'table', FILTER_VALIDATE_INT);
|
||||
|
||||
$lignes = [];
|
||||
$messageErreur = '';
|
||||
|
||||
if ($table === false || $table === null) {
|
||||
$messageErreur = 'Veuillez saisir un entier valide.';
|
||||
} else {
|
||||
for ($multiplicateur = 1; $multiplicateur <= 10; $multiplicateur++) {
|
||||
$lignes[] = [
|
||||
'multiplicateur' => $multiplicateur,
|
||||
'resultat' => $table * $multiplicateur,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
include_once 'include/controller.php';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
<title>Exercice 2</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h4>Table de multiplication</h4>
|
||||
<form method="GET">
|
||||
<input
|
||||
type="number"
|
||||
name="table"
|
||||
placeholder="table"
|
||||
value="<?php echo htmlspecialchars($table, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
>
|
||||
<button type="submit">ENVOYER</button>
|
||||
</form>
|
||||
|
||||
<?php if ($messageErreur !== '') : ?>
|
||||
<p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($table !== false && $table !== null) : ?>
|
||||
<ul>
|
||||
<?php foreach ($lignes as $ligne) : ?>
|
||||
<li>
|
||||
<?php echo htmlspecialchars((string) $table, ENT_QUOTES, 'UTF-8'); ?>
|
||||
x
|
||||
<?php echo htmlspecialchars((string) $ligne['multiplicateur'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
=
|
||||
<?php echo htmlspecialchars((string) $ligne['resultat'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
include_once 'include/controller.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Exercice 3</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico.min.css"
|
||||
/>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<h3>Calculatrice</h3>
|
||||
<form method="POST">
|
||||
<div class="grid">
|
||||
<input
|
||||
placeholder="un nombre"
|
||||
type="number"
|
||||
step="any"
|
||||
name="op1"
|
||||
value="<?php echo htmlspecialchars($valeurOp1, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
required
|
||||
>
|
||||
<select name="operation" required>
|
||||
<option value="+" <?php echo $operation === '+' ? 'selected' : ''; ?>>+</option>
|
||||
<option value="-" <?php echo $operation === '-' ? 'selected' : ''; ?>>-</option>
|
||||
<option value="x" <?php echo $operation === 'x' ? 'selected' : ''; ?>>x</option>
|
||||
<option value="/" <?php echo $operation === '/' ? 'selected' : ''; ?>>/</option>
|
||||
</select>
|
||||
<input
|
||||
placeholder="un nombre"
|
||||
type="number"
|
||||
step="any"
|
||||
name="op2"
|
||||
value="<?php echo htmlspecialchars($valeurOp2, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
required
|
||||
>
|
||||
<button type="submit" name="soumis">Calculer</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php if ($messageErreur !== '') : ?>
|
||||
<p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($aCalcule) : ?>
|
||||
<p>
|
||||
Résultat :
|
||||
<?php echo htmlspecialchars($valeurOp1, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
input[type="text"],
|
||||
select
|
||||
{
|
||||
display:inline-block;
|
||||
width:auto;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
$op1Saisi = filter_input(INPUT_POST, 'op1', FILTER_UNSAFE_RAW);
|
||||
$op2Saisi = filter_input(INPUT_POST, 'op2', FILTER_UNSAFE_RAW);
|
||||
$operationSaisie = filter_input(INPUT_POST, 'operation', FILTER_UNSAFE_RAW);
|
||||
|
||||
$op1Saisi = is_string($op1Saisi) ? trim($op1Saisi) : '';
|
||||
$op2Saisi = is_string($op2Saisi) ? trim($op2Saisi) : '';
|
||||
$operationSaisie = is_string($operationSaisie) ? trim($operationSaisie) : '+';
|
||||
|
||||
$operationsAutorisees = ['+', '-', 'x', '/'];
|
||||
$operation = in_array($operationSaisie, $operationsAutorisees, true) ? $operationSaisie : '+';
|
||||
|
||||
$resultat = null;
|
||||
$messageErreur = '';
|
||||
$aCalcule = false;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$op1 = filter_var($op1Saisi, FILTER_VALIDATE_FLOAT);
|
||||
$op2 = filter_var($op2Saisi, FILTER_VALIDATE_FLOAT);
|
||||
|
||||
if ($op1 === false || $op2 === false) {
|
||||
$messageErreur = 'Veuillez saisir deux nombres valides.';
|
||||
} elseif (!in_array($operation, $operationsAutorisees, true)) {
|
||||
$messageErreur = 'Veuillez choisir une opération valide.';
|
||||
} elseif ($operation === '/' && (float) $op2 == 0.0) {
|
||||
$messageErreur = 'La division par zéro est impossible.';
|
||||
} else {
|
||||
$aCalcule = true;
|
||||
|
||||
switch ($operation) {
|
||||
case '+':
|
||||
$resultat = $op1 + $op2;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
$resultat = $op1 - $op2;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
$resultat = $op1 * $op2;
|
||||
break;
|
||||
|
||||
case '/':
|
||||
$resultat = $op1 / $op2;
|
||||
break;
|
||||
|
||||
default:
|
||||
$messageErreur = 'Veuillez choisir une opération valide.';
|
||||
$aCalcule = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$valeurOp1 = $aCalcule ? (string) $resultat : $op1Saisi;
|
||||
$valeurOp2 = $op2Saisi;
|
||||
@@ -0,0 +1,14 @@
|
||||
button{
|
||||
|
||||
float:right;
|
||||
}
|
||||
|
||||
.bonne-reponse {
|
||||
color: #1b7f3a;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.mauvaise-reponse {
|
||||
color: #c62828;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
|
||||
<meta charset="UTF-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<h3>Quizz</h3>
|
||||
<form action="score.php" method="post">
|
||||
<fieldset>
|
||||
Quelle est la capitale de la France ?
|
||||
|
||||
<label class="radio">
|
||||
<input type="radio" name="question1" value="faux" > Lyon
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="question1" value="vrai"> Paris
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="question1" value="faux"> Marseille
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
Quelle est le nombre suivant de la suite 1,2,4,8 ?
|
||||
|
||||
<label class="radio">
|
||||
<input type="radio" name="question2" value="vrai" > 16
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="question2" value="faux"> 32
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
La bataille de Marignan a eu lieu en
|
||||
<label class="radio">
|
||||
<input type="radio" name="question3" value="faux" > 1492
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="question3" value="vrai"> 1515
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="question3" value="faux"> 1789
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit">Envoyer</button>
|
||||
</fieldset>
|
||||
<input type="hidden" value="3" name="nbq">
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
$nombreQuestions = 0;
|
||||
$score = 0;
|
||||
$questionsTraitees = 0;
|
||||
$message = 'Aucun resultat a afficher.';
|
||||
$resultatsParQuestion = [];
|
||||
|
||||
$nombreQuestionsSaisi = filter_input(INPUT_POST, 'nbq', FILTER_VALIDATE_INT);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $nombreQuestionsSaisi !== false && $nombreQuestionsSaisi !== null) {
|
||||
$nombreQuestions = $nombreQuestionsSaisi;
|
||||
$message = '';
|
||||
|
||||
for ($index = 1; $index <= $nombreQuestions; $index++) {
|
||||
$reponse = filter_input(INPUT_POST, 'question' . $index, FILTER_UNSAFE_RAW);
|
||||
|
||||
if ($reponse !== null) {
|
||||
$questionsTraitees++;
|
||||
}
|
||||
|
||||
if ($reponse === 'vrai') {
|
||||
$score++;
|
||||
$resultatsParQuestion[] = [
|
||||
'numero' => $index,
|
||||
'classe' => 'bonne-reponse',
|
||||
'message' => 'Bonne reponse',
|
||||
];
|
||||
} else {
|
||||
$resultatsParQuestion[] = [
|
||||
'numero' => $index,
|
||||
'classe' => 'mauvaise-reponse',
|
||||
'message' => 'Mauvaise reponse',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Exercice 4</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h4>Resultat du quizz</h4>
|
||||
<?php if ($message !== '') : ?>
|
||||
<p><?php echo htmlspecialchars($message, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||
<?php else : ?>
|
||||
<p>
|
||||
Vous avez obtenu
|
||||
<?php echo htmlspecialchars((string) $score, ENT_QUOTES, 'UTF-8'); ?>
|
||||
bonne(s) reponse(s) sur
|
||||
<?php echo htmlspecialchars((string) $nombreQuestions, ENT_QUOTES, 'UTF-8'); ?>.
|
||||
</p>
|
||||
<p>
|
||||
Questions repondues :
|
||||
<?php echo htmlspecialchars((string) $questionsTraitees, ENT_QUOTES, 'UTF-8'); ?>.
|
||||
</p>
|
||||
<ul>
|
||||
<?php foreach ($resultatsParQuestion as $resultatQuestion) : ?>
|
||||
<li>
|
||||
Question <?php echo htmlspecialchars((string) $resultatQuestion['numero'], ENT_QUOTES, 'UTF-8'); ?> :
|
||||
<span class="<?php echo htmlspecialchars($resultatQuestion['classe'], ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php echo htmlspecialchars($resultatQuestion['message'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<p>
|
||||
<a href="quizz.html">Revenir au quizz</a>
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
include_once 'include/controller.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
<title>Exercice 5</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h3>Conjugaison</h3>
|
||||
|
||||
<?php if ($messageErreur !== '') : ?>
|
||||
<p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
|
||||
<?php else : ?>
|
||||
<p>
|
||||
Verbe :
|
||||
<?php echo htmlspecialchars($verbe, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</p>
|
||||
|
||||
<?php foreach ($conjugaisons as $conjugaison) : ?>
|
||||
<section>
|
||||
<h4><?php echo htmlspecialchars($conjugaison['temps'], ENT_QUOTES, 'UTF-8'); ?></h4>
|
||||
<ul>
|
||||
<?php foreach ($conjugaison['formes'] as $forme) : ?>
|
||||
<li><?php echo htmlspecialchars($forme, ENT_QUOTES, 'UTF-8'); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<p>
|
||||
<a href="ex5.html">Retour au formulaire</a>
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,4 @@
|
||||
input[type="text"]{
|
||||
width:auto;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
|
||||
/>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<h3>Conjugaison</h3>
|
||||
<form method="post" action="conjuguer.php">
|
||||
<fieldset>
|
||||
<label>Verbe du premier groupe<br>
|
||||
<input type=text name="verbe" required>
|
||||
</label>
|
||||
Temps
|
||||
<label class="checkbox"><input type=checkbox name="temps[]" value="present"> Présent </label>
|
||||
<label class="checkbox"><input type=checkbox name="temps[]" value="futur"> Futur </label>
|
||||
<label class="checkbox"><input type=checkbox name="temps[]" value="imparfait"> Imparfait </label>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" name="accepter">Envoyer</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
$terminaisons = array(
|
||||
'present' => array('e', 'es', 'e', 'ons', 'ez', 'ent'),
|
||||
'futur' => array('erai', 'eras', 'era', 'erons', 'erez', 'eront'),
|
||||
'imparfait' => array('ais', 'ais', 'ait', 'ions', 'iez', 'aient')
|
||||
);
|
||||
|
||||
$libellesTemps = array(
|
||||
'present' => 'Present',
|
||||
'futur' => 'Futur',
|
||||
'imparfait' => 'Imparfait'
|
||||
);
|
||||
|
||||
$pronoms = array('je', 'tu', 'il', 'nous', 'vous', 'ils');
|
||||
|
||||
$verbeSaisi = filter_input(INPUT_POST, 'verbe', FILTER_UNSAFE_RAW);
|
||||
$verbeSaisi = is_string($verbeSaisi) ? trim($verbeSaisi) : '';
|
||||
$verbe = strtolower($verbeSaisi);
|
||||
|
||||
$tempsChoisis = filter_input(INPUT_POST, 'temps', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
|
||||
$tempsChoisis = is_array($tempsChoisis) ? $tempsChoisis : array();
|
||||
|
||||
$messageErreur = '';
|
||||
$conjugaisons = array();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if ($verbe === '') {
|
||||
$messageErreur = 'Veuillez saisir un verbe.';
|
||||
} elseif (strlen($verbe) < 3 || substr($verbe, -2) !== 'er') {
|
||||
$messageErreur = 'Veuillez saisir un verbe du premier groupe.';
|
||||
} elseif ($tempsChoisis === array()) {
|
||||
$messageErreur = 'Veuillez choisir au moins un temps.';
|
||||
} else {
|
||||
$radical = substr($verbe, 0, strlen($verbe) - 2);
|
||||
|
||||
foreach ($tempsChoisis as $temps) {
|
||||
if (!isset($terminaisons[$temps], $libellesTemps[$temps])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$formes = array();
|
||||
|
||||
foreach ($pronoms as $index => $pronom) {
|
||||
$forme = $radical . $terminaisons[$temps][$index];
|
||||
|
||||
if ($pronom === 'je' && preg_match('/^[aeiouh]/', $forme) === 1) {
|
||||
$formes[] = "j'" . $forme;
|
||||
} else {
|
||||
$formes[] = $pronom . ' ' . $forme;
|
||||
}
|
||||
}
|
||||
|
||||
$conjugaisons[] = array(
|
||||
'temps' => $libellesTemps[$temps],
|
||||
'formes' => $formes
|
||||
);
|
||||
}
|
||||
|
||||
if ($conjugaisons === array()) {
|
||||
$messageErreur = 'Aucun temps valide n a ete transmis.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||