Die Bestellung wird mit der GET-Methode an bestellung.php übermittelt. Die Namen der Felder lauten:
windhund, wgroesse, schleichkatze, sgroesse, agb
Auswählbare Schuhgrössen sind 38,39,40.41.42.43
Erstellen Sie den HTML-Quellcode für das Formular.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Turnschuhhändler</title>
<style type="text/css" media="screen"><!--
body { font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif; background-color: #ffef44; }
--></style>
</head>
<body>
<h2>Turnschuhhandlung</h2>
<form action="bestellung.php" method="get">
<table border="1" cellspacing="0" cellpadding="4">
<tr>
<th>Anzahl</th>
<th>Artikel</th>
<th>Preis</th>
<th>Grösse</th>
</tr>
<tr>
<td><input type="text" name="windhund" value="0" size="4" /></td>
<td>Windhund</td>
<td>150€</td>
<td><select name="wgroesse" size="1">
<option selected="selected" value="0">auswählen</option>
<option value="38">38</option>
<option value="39">38</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
</select></td>
</tr>
<tr>
<td><input type="text" name="schleichkatze" value="0" size="4" /></td>
<td>Schleichkatze</td>
<td>200€</td>
<td><select name="sgroesse" size="1">
<option selected="selected" value="0">auswählen</option>
<option value="38">38</option>
<option value="39">38</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
</select></td>
</tr>
<tr>
<td colspan="3"><input type="checkbox" name="agb" value="true" /> Ich bin mit der AGB einverstanden.</td>
<td><input type="submit" name="" value="Bestellen" /></td>
</tr>
</table>
</form>
</body>
</html>
Auswertung der Eingaben.
Erstellen Sie PHP-Code oder ein Struktogramm für ein Unterprogramm bestellung(windhund, wgroesse,schleichkatze, sgroesse:GZ, agb:Bool) .
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Bestellung</title>
<style type="text/css" media="screen"><!--
body { font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif; background-color: #ff3; }
--></style>
</head>
<body>
<h2>Vielen Dank für Ihren Auftrag</h2>
<p><?php
if (isset($_GET['windhund']) && $_GET['wgroesse'] && isset($_GET['schleichkatze']) && $_GET['sgroesse'])
bestellung($_GET['windhund'],$_GET['wgroesse'],$_GET['schleichkatze'],$_GET['sgroesse'],$_GET['agb']);
else
echo 'Keine gültige Anfrage!';
function bestellung($windhund, $wgroesse, $schleichkatze, $sgroesse, $agb){
$ok = true;
if ($windhund==0 && $schleichkatze == 0)
echo 'Sie haben nichts bestellt.';
else if ($agb!='true')
echo 'Sie haben der AGB nicht zu gestimmt.';
else{
if ($windhund>0 && $wgroesse <=0){
echo 'Bitte Schuhgrösse für Windhund auswählen';
$ok=false;
}
if ($schleichkatze>0 && $sgroesse <=0){
echo 'Bitte Schuhgrösse für Schleichkatze auswählen';
$ok=false;
}
if ($ok){
if ($windhund>0){
echo 'Sie haben '.$windhund.' Windhund Grösse '.$wgroesse.' bestellt.<br>';
$summe = $windhund*150;
}
if ($schleichkatze>0){
echo 'Sie haben '.$schleichkatze.' Schleichkatze Grösse '.$sgroesse.' bestellt.<br>';
$summe += $schleichkatze*200;
}
echo '<br>Die Bestellsumme beträgt: '.$summe.' Euro.';
}
}
}
?></p>
</body>
</html>