Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercises/formulär/

ovn_form1.php
ovn_form2.php
ovn_form3.php
ovn_form4.php
ovn_form5.php
ovn_form6.php
ovn_form7.php
ovn_form7res.php
ovn_form8.php

ovn_form8.php

35 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Formulär 8</title>
</head>
<body>
  <?php
    $tal 
$tal2 $tal3 "";

    function 
medelVärde($tal1$tal2$tal3) {
      return (
$tal1 $tal2 $tal3)/3;
    }

  
?>

  <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    Skriv ett tal i varje ruta: <br>
    Tal1: <input type="text" name="tal1" required> <br>
    Tal2: <input type="text" name="tal2" required> <br>
    Tal3: <input type="text" name="tal3" required> <br>
    <input type="submit" value="Beräkna">

  </form>
  <br>

  <?php
  
if ( isset($_POST["tal1"]) && isset($_POST["tal2"]) && isset($_POST["tal3"]) ) {
    echo 
"Medelvärde: "medelVärde($_POST["tal1"], $_POST["tal2"], $_POST["tal3"]);
  }
  
?>
</body>
</html>