Académique Documents
Professionnel Documents
Culture Documents
TD1 Correction Formulaires PHP
TD1 Correction Formulaires PHP
Menu.html
<html>
>
<head><title>Passage 1 - Menu restaurant</title></head>
<body>
<h1>Composez votre menu</h1>
<form method="GET" action="calcul.php">
<table>
<tr>
<td><b>Plat</b><br>
<select name="plat">
<option value="po" selected>Poulet</option>
<option value="pi">Pizza</option>
</select>
</td>
<td><b>Dessert</b><br>
<input type="radio" name="dessert" value="ju" checked>Jus</option>
<input type="radio" name="dessert" value="gl">Glace</option>
</td>
</tr>
<tr>
<td><input type="checkbox" name="emporter" >A emporter</td>
</tr>
</table>
<input type="submit" value="Commander">
</form>
</body>
</html>
fonctions.php
<?php
/* Fonction qui calcule la somme de deux entiers */
function somme($x, $y){
return $x+$y;
}
?>
1/2
Calcul.php
<html>
<head><title>Menu</title></head>
<body>
<?php
/*Tableau associatif contenant la liste des prix*/
$prix=array('po' => 9.000,
'pi' => 7.000,
'ju' => 4.500,
'gl' => 3.500);
/*Récupération de clés*/
$plat = $_GET['plat'];
$dessert = $_GET['dessert'];
if($a_emporter){
$total = $total + $emballage;
$emporter_txt = "oui";
}
echo $msg;
?>
</body>
</html>
2/2