daily pastebin goal
72%
SHARE
TWEET

10Formularze w php zadanie 1 Rozkwitalski/Kuling/Krajnik

a guest Nov 21st, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html> <html lang="pl">
  2. <head>
  3. <meta charset="utf-8"> <title>Formularze</title>
  4. <meta http-equiv="X-Ua-Compatible" content="IE=edge,chrome=1">
  5. </head>
  6. <body>
  7. <br>
  8. <br>
  9. <form method="post">
  10. <label>A: <input type="text" name="aa" /></label>
  11. <label>B: <input type="text" name="bb" /></label> <br>
  12. <input type="radio" name="ans" value="+"/> + <br>
  13. <input type="radio" name="ans" value="-"/> - <br>
  14. <input type="radio" name="ans" value="*"/> * <br>
  15. <input type="radio" name="ans" value=":"/> : <br>
  16. <input type="submit" value="Oblicz" />
  17. <input type="reset" value="Wyczyść" />
  18. </form>
  19. <?php
  20. $a = $_POST['aa'];
  21. $b = $_POST['bb'];
  22. $answer = $_POST['ans'];
  23.  
  24. if ($answer == "+"){
  25.     $wynik = $a + $b;
  26.     echo $wynik;
  27. }
  28.  
  29. if ($answer == "-"){
  30.     $wynik = $a - $b;
  31.     echo $wynik;
  32. }
  33.  
  34. if ($answer == "*"){
  35.     $wynik = $a * $b;
  36.     echo $wynik;
  37. }
  38.  
  39. if ($answer == ":"){
  40.     $wynik = $a / $b;
  41.     echo $wynik;
  42. }
  43. ?>
  44. </body>
  45. </html>
RAW Paste Data
Top