Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1.  
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. </head>
  6. <body>
  7. <?php
  8. if (isset($_GET['N1'])){
  9. $a = ($_GET['N1']);
  10. }
  11. if (isset($_GET['N2'])) {
  12. $b = ($_GET['N2']);
  13. }
  14. ?>
  15. <form >
  16. Number 1: <input type="text" name="N1" value="<?php
  17. if (isset($_GET['N1'])){
  18. echo ($_GET['N1']);
  19. } ?>" > <br>
  20. Number 2: <input type="text" name="N2" value="<?php if (isset($_GET['N2'])) {
  21. echo ($_GET['N2']);
  22. } ?>"> <br>
  23. <hr>
  24. <input type="radio" name="Operation" value="+"> + <br>
  25. <input type="radio" name="Operation" value="-"> - <br>
  26. <input type="radio" name="Operation" value="*"> * <br>
  27. <input type="radio" name="Operation" value="/"> / <br>
  28. <hr>
  29. <br> <input type="submit" name="submit" value="="> <br>
  30. <?php
  31. switch( $_GET['Operation'] ) {
  32. case '+':
  33. echo $a + $b ;
  34. break;
  35. case '-' :
  36. echo $a - $b ;
  37. break;
  38. case '*':
  39. echo $a * $b ;
  40. break;
  41. case '/' :
  42. if ($b == 0) {
  43. echo 'error';
  44. }
  45. else {
  46. echo $a / $b ;
  47. }
  48. break;
  49. }
  50. ?>
  51. </form>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement