update
This commit is contained in:
24
DEV.2.2/TP/TP2/ex1controller.php
Normal file
24
DEV.2.2/TP/TP2/ex1controller.php
Normal file
@@ -0,0 +1,24 @@
|
||||
//controller.php
|
||||
|
||||
<?php
|
||||
$prenom = $_POST['prenom'];
|
||||
$nom = $_POST['nom'];
|
||||
$os = $_POST['os'];
|
||||
$button = $_POST['button'];
|
||||
|
||||
if(ctype_upper($prenom)) {
|
||||
$prenom = strtolower($prenom);
|
||||
}
|
||||
ucfirst($prenom);
|
||||
if(ctype_upper($nom)){
|
||||
$nom = strtolower($nom);
|
||||
}
|
||||
ucfirst($nom);
|
||||
|
||||
if($button){
|
||||
echo"<ul>";
|
||||
echo"<li>$prenom $nom</li>";
|
||||
echo"<li>$os</li>";
|
||||
echo"</ul>";
|
||||
}
|
||||
?>
|
54
DEV.2.2/TP/TP2/ex1index.html
Normal file
54
DEV.2.2/TP/TP2/ex1index.html
Normal file
@@ -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 name="button" type="submit">Envoyer</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
10
DEV.2.2/TP/TP2/ex2.php
Normal file
10
DEV.2.2/TP/TP2/ex2.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$table = $_GET['table'];
|
||||
echo"<h1>Table de $table</h1>";
|
||||
echo"<ul>"
|
||||
for($i=1;$i!=$table;$i++) {
|
||||
$res = $i*$table;
|
||||
echo"<li>$i x $table = $res</li>";
|
||||
}
|
||||
echo"</ul>";
|
||||
?>
|
25
DEV.2.2/TP/TP2/ex2multiplication.php
Normal file
25
DEV.2.2/TP/TP2/ex2multiplication.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
include 'include/controller.php';
|
||||
?>
|
||||
<!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"
|
||||
/>
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h4>Table de multiplication</h4>
|
||||
|
||||
<form method="GET">
|
||||
<input type=number name="table" placeholder="table">
|
||||
<button type="submit">ENVOYER</button>
|
||||
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
22
DEV.2.2/TP/TP2/ex3.php
Normal file
22
DEV.2.2/TP/TP2/ex3.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php //première version
|
||||
$op1 = $_POST['op1'];
|
||||
$op2 = $_POST['op2'];
|
||||
$operation = $_POST['operation'];
|
||||
if($soumis){
|
||||
if($operation == '/' && $op2 == 0) {
|
||||
echo"<h3>On ne peut pas diviser par 0.</h3>";
|
||||
exit();
|
||||
} else {
|
||||
if($operation == '+') {
|
||||
$res = $op1+$op2;
|
||||
} elseif ($operation == '-') {
|
||||
$res = $op1-$op2;
|
||||
} elseif ($operation == 'x') {
|
||||
$res = $op1*$op2;
|
||||
} elseif ($operation == '/') {
|
||||
$res = $op1/$op2;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
34
DEV.2.2/TP/TP2/ex3calculatrice.php
Normal file
34
DEV.2.2/TP/TP2/ex3calculatrice.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include 'include/controller.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title></title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/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 ="" required>
|
||||
<select name="operation" required>
|
||||
<option value="+">+</option>
|
||||
<option value="-">-</option>
|
||||
<option value="x">x</option>
|
||||
<option value="/">/</option>
|
||||
</select>
|
||||
<input placeholder="un nombre" type="number" step="any" name="op2" required>
|
||||
<button type="submit" name="soumis"> Calculer</button>
|
||||
</grid>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
30
DEV.2.2/TP/TP2/ex4.php
Normal file
30
DEV.2.2/TP/TP2/ex4.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// Récupération du nombre de questions
|
||||
$nbq = isset($_POST['nbq']) ? (int)$_POST['nbq'] : 0;
|
||||
$score = 0;
|
||||
|
||||
// Début du HTML pour l'affichage du résultat
|
||||
echo '<!DOCTYPE html><html lang="fr"><head>';
|
||||
echo '<link rel="stylesheet" href="./css/style.css">';
|
||||
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css">';
|
||||
echo '<meta charset="UTF-8"><title>Résultats</title></head><body><main>';
|
||||
echo '<h4>Réponses</h4><ul>';
|
||||
|
||||
// Boucle sur chaque question
|
||||
for ($i = 1; $i <= $nbq; $i++) {
|
||||
$question = "question" . $i;
|
||||
if (isset($_POST[$question])) {
|
||||
if ($_POST[$question] === "vrai") {
|
||||
echo "<li>Question $i : <span style='color: green;'>bonne réponse</span></li>";
|
||||
$score++;
|
||||
} else {
|
||||
echo "<li>Question $i : <span style='background-color: #fdd;'>mauvaise réponse</span></li>";
|
||||
}
|
||||
} else {
|
||||
echo "<li>Question $i : <span style='background-color: #fdd;'>non répondue</span></li>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</ul><p><strong>Score : $score</strong></p>";
|
||||
echo '</main></body></html>';
|
||||
?>
|
61
DEV.2.2/TP/TP2/ex4quizz.html
Normal file
61
DEV.2.2/TP/TP2/ex4quizz.html
Normal file
@@ -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>
|
54
DEV.2.2/TP/TP2/ex5/conjuguer.php
Normal file
54
DEV.2.2/TP/TP2/ex5/conjuguer.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// Terminaisons par temps
|
||||
$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")
|
||||
);
|
||||
|
||||
// Pronoms personnels
|
||||
$pronoms = array("je", "tu", "il", "nous", "vous", "ils");
|
||||
|
||||
// Récupération des données POST
|
||||
$verbe = filter_input(INPUT_POST, "verbe", FILTER_SANITIZE_STRING);
|
||||
$tempsChoisis = $_POST['temps'] ?? [];
|
||||
|
||||
// Vérification que le verbe se termine par "er"
|
||||
if (!$verbe || substr($verbe, -2) !== 'er') {
|
||||
die("Le verbe doit être du premier groupe (terminé par -er).");
|
||||
}
|
||||
|
||||
$radical = substr($verbe, 0, -2); // Enlève "er"
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Conjugaison</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h3>Conjugaison du verbe « <?= htmlspecialchars($verbe) ?> »</h3>
|
||||
|
||||
<?php foreach ($tempsChoisis as $temps): ?>
|
||||
<?php if (isset($terminaisons[$temps])): ?>
|
||||
<section>
|
||||
<h4><?= ucfirst($temps) ?></h4>
|
||||
<ul>
|
||||
<?php foreach ($terminaisons[$temps] as $i => $terminaison): ?>
|
||||
<li><?= $pronoms[$i] . ' ' . $radical . $terminaison ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($tempsChoisis)): ?>
|
||||
<p>Aucun temps sélectionné.</p>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
4
DEV.2.2/TP/TP2/ex5/css/style.css
Normal file
4
DEV.2.2/TP/TP2/ex5/css/style.css
Normal file
@@ -0,0 +1,4 @@
|
||||
input[type="text"]{
|
||||
width:auto;
|
||||
|
||||
}
|
31
DEV.2.2/TP/TP2/ex5/ex5.html
Normal file
31
DEV.2.2/TP/TP2/ex5/ex5.html
Normal file
@@ -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>
|
12
DEV.2.2/TP/TP2/ex5/include/controller.php
Normal file
12
DEV.2.2/TP/TP2/ex5/include/controller.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?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")
|
||||
);
|
||||
|
||||
$pronoms=array("je","tu","il","nous","vous","ils");
|
||||
|
||||
$verbe = filter_input(INPUT_POST,"verbe",FILTER_SANITIZE_STRING);
|
||||
$radical = substr($verbe,0,strlen($verbe)-2);
|
||||
|
Reference in New Issue
Block a user