Erst mal das Formular bauen
Quelltext für Verarbeitung
<?php if ($_GET['km']){ echo '<h4>Ihre Eingaben: '. $_GET['liter'] . ' Liter auf ' . $_GET['km'] . ' Km.<br> Der Verbrauch ist: '. round($_GET['liter'] / $_GET['km'] *100,2) . ' l/100km</h4>' ; } else { echo '<h4> Noch nichts zu verarbeiten! </h4>'; } ?>
Mehr zu round()...
Hier steht das Ergebnis
Noch nichts zu verarbeiten!
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <meta name="title" content="Formular mit PHP"> <meta name="page-topic" content="Webpublishing"> <meta name="Keywords" content="SAE, Fachinformatiker, TG, TGIT, ITG"> <link href="../../style/computer-style.css" type="text/css" rel="stylesheet"> <?php include '../../lib/kopf.inc' ?> </head> <body> <?php kopf2(); ?> <h3>Erst mal das Formular bauen</h3> <table border="2" cellspacing="0" cellpadding="8" bgcolor="#ffff99"> <tr> <td> <form id="FormName" action="index.php" method="get" name="FormName"> <h4>Benzinrechner zur Verbrauchsberechnung</h4> <p>Liter <input type="text" name="liter" size="24"></p> <p>Km <input type="text" name="km" size="24"></p> <p><input type="submit" name="" value="Verbrauch berechnen"></p> </form> </td> </tr> </table> <h3>Quelltext für Verarbeitung</h3> <pre><?php if ($_GET['km']){ echo '<h4>Ihre Eingaben: '. $_GET['liter'] . ' Liter auf ' . $_GET['km'] . ' Km.<br> Der Verbrauch ist: '. round($_GET['liter'] / $_GET['km'] *100,2) . ' l/100km</h4>' ; } else { echo '<h4> Noch nichts zu verarbeiten! </h4>'; } ?> </pre> <p>Mehr zu <a href="http://de2.php.net/manual/de/function.round.php"><b>round()..</b></a>.</p> <h3>Hier steht das Ergebnis</h3> <p> <?php if ($_GET['km']){ echo '<h4>Ihre Eingaben: '. $_GET['liter'] . ' Liter auf ' . $_GET['km'] . ' Km.<br> Der Verbrauch ist: '. round($_GET['liter'] / $_GET['km'] *100,2) . ' l/100km</h4>' ; } else { echo '<h4> Noch nichts zu verarbeiten! </h4>'; } ?> </p> <p> </p> <?php quelltext('index.php'); ?> <?php fuss(); ?> </body> </html>