Webbserverprogrammering 1

Show sourcecode

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

webbserverprogrammering/exercises/repetition/

ovning_1.php
ovning_2.php
ovning_3a.php
ovning_3b.php
ovning_3c.php
ovning_4.php
ovning_5.php
ovning_6.php
ovning_7.php

ovning_4.php

39 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">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
  <title>Övning 4</title>
</head>
<body>
  <?php
    
if(!isset($_POST["name"]) && !isset($_POST["fav-food"])) {
    
?>

      <form method="post">
        <label for="name">Ange ditt namn</label>
        <input name="name" id="name" type="name" placeholder="Ange ditt namn" required>

        <label for="fav-food">Vad är din favoritmat?</label>
        <select name="fav-food" id="fav-food">
          <option value="VGY burgaren">VGY burgaren</option>
          <option value="barn">Små barn!</option>
          <option value="Tobias specialpizza">Tobias specialpizza (extra sås)</option>
        </select>

        <button type="submit">Skicka</button>
      </form>

    <?php
    
} else {

      
$name $_POST["name"];
      
$fav_food $_POST["fav-food"];

      echo 
"Hej $name! Du gillar $fav_food!";

    }
  
?>
</body>
</html>