Webbserverprogrammering 1

Show sourcecode

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

Webserver1/Ovningar/Repetition/

rep1.php
rep2.php
rep3b.php
rep3c.php
rep4.php
rep5.php

rep4.php

36 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>Repetition Repetition Repetition</title>
</head>

<body>
  <?php
  $name 
= (isset($_GET["name"])) ? $_GET["name"] : null;
  
$food = (isset($_GET["food"])) ? implode(", "$_GET["food"]) : "ingenting";

  if (isset(
$name)) {
    echo 
"Hej $name! Du gillar $food.";
  } else {
  
?>
    <form action="" method="get">
      <label for="name">Vad är ditt namn?</label>
      <input type="text" name="name">
      <br>
      <label for="food">Vilka är dina favoriträtt(er)?</label>
      <input type="checkbox" name="food[]" value="Lasange">Lasange</input>
      <input type="checkbox" name="food[]" value="Sushi">Sushi</input>
      <input type="checkbox" name="food[]" value="Kötbullar">Kötbullar</input>
      <input type="checkbox" name="food[]" value="Weinerbröd">Weinerbröd</input>
      <br>
      <input type="submit" value="Skicka">
    </form>
  <?php
  
}
  
?>
</body>

</html>