-
Notifications
You must be signed in to change notification settings - Fork 0
/
jeu.php
83 lines (70 loc) · 1.59 KB
/
jeu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
$title = "Composez votre glace";
require 'header.php';
//Checkbox
$parfums = [
'Fraise' => 4,
'Chocolat' => 5,
'Vanille' => 3
];
//Radio
$cornets = [
'Pot' => 2,
'Cornet' => 4
];
//checkbox
$supplements = [
'Pépites de chocolat' => 1,
'Chantilly' => 0.5
];
?>
<h1>Composez votre glace</h1>
<form action="jeu.php" method="post">
<?php foreach ($parfums as $parfum => $prix): ?>
<div class="checkbox">
<label>
<?= checkbox ('parfum, $parfum, $_POST') ?>
<?= $parfum ?> - <?= $prix ?> €
</label>
</div>
<?php endforeach; ?>
<button type="submit" class="btn btn-secondary">Composer ma glace</button>
</form>
<pre>
<?php var_dump($_POST); ?>
</pre>
<?php
require 'footer.php';
/* EXERCICE 1
$aDeviner = 150;
$error = null;
$success = null;
$value = null;
if (isset($_POST['chiffre'])) {
$value = (int)$_POST['chiffre'];
if ( $value > $aDeviner) {
$error = "Votre chiffre est trop grand";
} elseif ($value < $aDeviner) {
$error = " Votre chiffre est trop petit";
} else {
$success = "Bravo ! Vous avez deviné le bon chiffre <strong> $aDeviner";
}
}
?>
<?php if ($error): ?>
<div class="alert alert-danger">
<?= $error ?></div>
<?php elseif ($success): ?>
<div class="alert alert-success">
<?= $success ?>
</div>
<?php endif; ?>
<form action="jeu.php" method="post">
<div class="form-group">
<input type="text" name="chiffre" placeholder="entre 0 et 1000"
value="<?= $value ?>">
</div>
<button type="submit" class="btn btn-secondary">Deviner</button>
</form>
*/
?>