Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/form/

egetformular/
form.html
form1.php
form2.php
form3.php
form4.php
form5.php
form6.php
form7.php
ovn_form1.php
ovn_form2.php
ovn_form3.php
ovn_form4.php
ovn_form5.php
ovn_form6.php
ovn_form7.php
ovn_form8.php

form6.php

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

<?php 
echo "Hej " $_POST["name"] . " " $_POST["aftername"] . " i " $_POST["class"] . "!<br>"

echo 
" <br>Din favorit kurs är " $_POST["kurs"]; 
?>
<br><br>
<?php

function printFood($foodArray) {
    if (empty(
$foodArray)) {
        
        return 
"";
    } elseif (
count($foodArray) == 1) {
        
        return 
"Din favoritmaträtt är " $foodArray[0] . ".";
    } else {
       
        return 
"Dina favoritmaträtter är " implode(", "$foodArray) . ".";
    }
}


if (isset(
$_POST["food"])) {
    echo 
printFood($_POST["food"]);  
} else {
    echo 
"Du har inte valt någon favoritmaträtt.";
}
?>


</body>
</html>