Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/

fragotavling.php
index.php
ovn_cookie.php
ovn_cookie1.php
ovn_cookie2.php
ovn_cookie4.php
ovn_cookie5.php
ovn_cookie_hemligt.php
ovn_cookie_login.php
ovn_form.php
ovn_form2.php
ovn_form3.php
ovn_form4.php
ovn_form6.php
ovn_form7.php
ovn_form8.php
ovn_formular.php
ovn_formular_svar.php
ovn_formular_svar2.php
ovn_formular_svar3.php
ovn_formular_svar4.php
ovn_formular_svar6.php
ovn_formular_svar7.php
ovn_funktioner.php
ovn_gr1.php
ovn_inklfiler.php
ovn_inklfiler2_1.php
ovn_inklfiler2_2.php
ovn_inklfiler2_3.php
ovn_inklfiler_slut.php
ovn_inklfiler_start.php
ovn_inklfiler_test.php
ovn_strangar.php

ovn_form8.php

27 lines UTF-8 Windows (CRLF)
<?php

function medelvarde($tal1, $tal2, $tal3) {
    return (
$tal1 + $tal2 + $tal3) / 3;
}

if (isset(
$_POST["tal1"])) {
    
$tal1 = $_POST["tal1"];
    
$tal2 = $_POST["tal2"];
    
$tal3 = $_POST["tal3"];

    
$medel = medelvarde($tal1, $tal2, $tal3);

    echo 
"Tal 1: $tal1<br>";
    echo 
"Tal 2: $tal2<br>";
    echo 
"Tal 3: $tal3<br>";
    echo 
"Medelvärde: $medel<br><br>";
}
?>

<form action="" method="POST">
    Tal 1: <input type="text" name="tal1"><br>
    Tal 2: <input type="text" name="tal2"><br>
    Tal 3: <input type="text" name="tal3"><br>

    <input type="submit" value="Beräkna">
</form>