Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/

index.php
ovn1_gr.php
ovn2_fn.php
ovn3_inkl.php
ovn3_inklfil.php
ovn3_inklfil2.php
ovn3_inklsida1.php
ovn3_inklsida2.php
ovn3_inklsida3.php
ovn3_inklsidafil.php
ovn4_form.php
ovn4_mottagare.php
ovn4_mottagare2.php
ovn4_mottagare3.php
ovn4_mottagare4.php
quiz.php

ovn4_form.php

99 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <?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
    
?>

    1. Vad är ditt namn?<br>
    <form method="POST" action="ovn4_mottagare.php">
        <input type="text" name="namn">
        <input type="submit" value="Skicka">
    </form><br>

    2. Vad heter du?<br>
    <form method="GET" action="ovn4_mottagare2.php">
        <input type="text" name="namn">
        <input type="submit" value="Skicka">
    </form><br>

    3. Vad är ditt förnamn?<br>
    <form method="POST" action="ovn4_mottagare3.php">
        <input type="text" name="fnamn"><br><br>
        Vad är ditt efternamn?<br>
        <input type="text" name="enamn"><br><br>
        Vilken klass går du i?<br>
        <input type="text" name="klass"><br><br>
        Vad är din favorit maträtt?<br>
        <input type="checkbox" id="pizza" name="mat[]" value="pizza">
        <label for="pizza">Pizza</label><br>
        <input type="checkbox" id="kebab" name="mat[]" value="kebab">
        <label for="kebab">Kebab</label><br>
        <input type="checkbox" id="hamburgare" name="mat[]" value="hamburgare">
        <label for="hamburgare">Hamburgare</label><br>
        <input type="checkbox" id="tacos" name="mat[]" value="tacos">
        <label for="tacos">Tacos</label><br><br>

        Vad är din favorit kurs?<br>
        <input type="radio" id="matte" name="kurs" value="matte">
        <label for="matte">Matte</label><br>
        <input type="radio" id="fysik" name="kurs" value="fysik">
        <label for="fysik">Fysik</label><br>
        <input type="radio" id="programering" name="kurs" value="programering">
        <label for="programering">Programering</label><br>
        <input type="radio" id="kemi" name="kurs" value="kemi">
        <label for="kemi">Kemi</label><br>
        <input type="radio" id="webbserverprogramering" name="kurs" value="webbserverprogramering">
        <label for="webbserverprogramering">Webbserverprogramering</label><br><br>

        Vad är din e-postadress?<br>
        <input type="email" name="epost"><br><br>
        <input type="submit" value="Skicka"><br><br>
    </form>

    <form method="POST" action="ovn4_mottagare4.php">
        7. Skriv tre nummer<br>
        tal 1:
        <textarea id="tal1" name="tal1"></textarea><br>
        tal 2:
        <textarea id="tal2" name="tal2"></textarea><br>
        tal 3:
        <textarea id="tal3" name="tal3"></textarea><br>
        <input type="submit" value="Beräkna"><br><br>
    </form>

    <form method="POST" action="ovn4_form.php">
        8. Skriv tre nummer <br>
        tal 1:
        <textarea id="nummer1" name="nummer1"></textarea><br>
        tal 2:
        <textarea id="nummer2" name="nummer2"></textarea><br>
        tal 3:
        <textarea id="nummer3" name="nummer3"></textarea><br>
        <input type="submit" value="Beräkna"><br>
    </form>
    <?php
    
function medel(int $tal1, int $tal2, int $tal3)
    {
        
$medel = ($tal1 + $tal2 + $tal3) / 3;
        return 
$medel;
    }
    if (isset(
$_POST["nummer1"], $_POST["nummer2"], $_POST["nummer3"])) {
        
$tal1 = $_POST["nummer1"];
        
$tal2 = $_POST["nummer2"];
        
$tal3 = $_POST["nummer3"];
        echo 
"Tal: " . $tal1 . ", " . $tal2 . ", " . $tal3 . "<br>Medelvärde: " . medel($tal1, $tal2, $tal3);
    };
    
?>
</body>

</html>