Webbserverprogrammering 1

Show sourcecode

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

webbserverprogramering/exercises/

phpstartsida.php
uppgiftForm_1.php
uppgiftFunk_1.php
uppgiftFunk_2.php
uppgiftFunk_3.php
uppgiftFunk_4.php
uppgiftFunk_5.php
uppgiftFunk_6.php
uppgiftIncl_1.php
uppgiftIncl_1_incl.php
uppgiftIncl_2_1.php
uppgiftIncl_2_2.php
uppgiftIncl_2_3.php
uppgiftIncl_2_slut.php
uppgiftIncl_2_start.php
uppgiftIncl_2_tal.php
uppgiftQuiz.php
uppgiftString_1.php
uppgiftString_2.php
uppgiftString_3.php
uppgiftString_4.php
uppgiftString_5.php
uppgift_1.php
uppgift_2.php
uppgift_3.php
uppgift_4.php
uppgift_5.php

uppgiftString_3.php

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

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

<body>
    <form action="" method="post">
        <input type="text" name="tal1" placeholder="Första talet: täljaren">
        <br><br>
        <input type="text" name="tal2" placeholder="Andra talet: nämnaren">
        <br><br>
        <button type="submit" name="sent" value="1">Skicka</button>
    </form>

    <?php
    
if (isset($_POST["sent"])) {
        if (
$_POST["tal1"] != "") {
            if (
mb_ereg_match('^[0-9]+$', $_POST["tal1"])) {
            } else {
                echo 
"<br> Du får ändast använda sifror i kolumnen: Första talet";
            }
        } else {
            echo 
"<br> Fyll i första talet";
        }

        if (
$_POST["tal2"] != "") {
            if (
mb_ereg_match('^[0-9]+$',$_POST["tal2"])) {
            } else {
                echo 
"<br> Du får ändast använda sifror i kolumnen: Andra talet";
            }
        } else {
            echo 
"<br> Fyll i andra talet";
        }

        if (
ctype_digit($_POST["tal1"]) && ctype_digit($_POST["tal2"])) {
           
$sum = round($_POST["tal1"] / $_POST["tal2"], 2);
           echo 
"<br> Kvoten av ". $_POST["tal1"]. " delat på ". $_POST["tal2"]. " är ". $sum;
        }
    }
    
?>
</body>

</html>