Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/formulär/
form1.php
form2.php
form3.php
form4.php
form5.php
form6.php
form7.php
form8.php
form7.php
41 lines UTF-8 Windows (CRLF)
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Formulär 7</title>
</head>
<body>
<?php
if (isset($_POST["tal1"]) && isset($_POST["tal2"]) && isset($_POST["tal3"])) {
$tal1 = $_POST["tal1"];
$tal2 = $_POST["tal2"];
$tal3 = $_POST["tal3"];
echo $tal1."<br>".$tal2."<br>".$tal3."<br>Medelvärde:".(($tal1+$tal2+$tal3)/3);
}
else{
?>
<form method="post" action="">
<table>
<tr>
<td>Skriv in tre tal:<br><input type="text" name="tal1"></td>
</tr>
<tr>
<td><input type="text" name="tal2"></td>
</tr>
<tr>
<td><input type="text" name="tal3"></td>
</tr>
</table>
<input type="submit" value="Beräkna">
</form>
<?php } ?>
</body>
</html>