Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/textstrangar/

ovn_text1.php
ovn_text2.php
ovn_text3.php
ovn_text4.php
ovn_text5.php
ovn_text6.php

ovn_text3.php

44 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Textsträng 3</title>
</head>
<body>
  <?php
    $tal1 
$tal2 $kvot 0;

    if (
$_SERVER["REQUEST_METHOD"] == "POST") {
      if (isset(
$_POST["tal1"]) && $_POST["tal1"]!="") {
        
$tal1 intval($_POST["tal1"]);
      }

      if (isset(
$_POST["tal2"]) && $_POST["tal2"]!="") {
        
$tal2 intval($_POST["tal2"]);
      }

      
$kvot round(($tal1/$tal2), 2);
      
    }

  
?>
  <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  Tal 1: <input type="text" name="tal1" required> <br>
  Tal 2: <input type="text" name="tal2" required> <br>

  <input type="submit" value="Skicka">

  </form>

  <?php
    
if (isset($_POST["tal1"]) && $_POST["tal1"]!="" && isset($_POST["tal2"]) && $_POST["tal2"]!="") {
      echo 
"Tal 1: "$tal1"<br>";
      echo 
"Tal 2: "$tal2"<br>";
      echo 
"Kvot: "$kvot;
    }

  
?>
</body>
</html>