Make a calc.


SUBMITTED BY: Guest

DATE: May 11, 2015, 9:59 a.m.

FORMAT: PHP

SIZE: 4.6 kB

HITS: 1093

  1. <?php
  2. $nr1 = $_POST['nr1'];
  3. $nr2 = $_POST['nr2'];
  4. $nr3 = $_POST['nr3'];
  5. $C = $_POST['C'];
  6. $A = $_POST['A'];
  7. $B = $_POST['B'];
  8. $operator = $_POST['operator'];
  9. $noerror = 0;
  10. $emptya = 0;
  11. $emptyb = 0;
  12. $emptyc = 0;
  13. if(isset($_POST['submit']))
  14. {
  15. if($operator == "+") {
  16. $noerror = 1;
  17. $result=$nr1+$nr2;
  18. $sukses = $result;
  19. }
  20. elseif($operator == "-") {
  21. $noerror = 1;
  22. $result=$nr1-$nr2;
  23. $sukses = $result;
  24. }
  25. elseif($operator == "*") {
  26. $noerror = 1;
  27. $result=$nr1*$nr2;
  28. $sukses = $result;
  29. }
  30. elseif($operator == "/") {
  31. $noerror = 1;
  32. $result=$nr1/$nr2;
  33. $sukses = $result;
  34. }
  35. elseif($operator == "v") {
  36. $noerror = 1;
  37. $result=sqrt($nr1);
  38. $sukses = $result;
  39. }
  40. }
  41. if(isset($_POST['submit1']))
  42. {
  43. if($nr1 == "" && $nr2 != "" && $nr3 != "") {
  44. $emptyc = 1;
  45. $noerror = 1;
  46. $result1=pow($nr2, 2) + pow($nr3, 2); // Gjej C
  47. $result=sqrt($result1);
  48. $sukses1 = $result;
  49. }
  50. elseif($nr1 != "" && $nr2 == "" && $nr3 != "") {
  51. $emptya = 1;
  52. $noerror = 1;
  53. $result1=pow($nr1, 2) - pow($nr3, 2); // Gjej A
  54. $result=sqrt($result1);
  55. $sukses1 = $result;
  56. }
  57. elseif($nr1 != "" && $nr2 != "" && $nr3 == "") {
  58. $emptyb = 1;
  59. $noerror = 1;
  60. $result1=pow($nr1, 2) - pow($nr2, 2); // Gjej B
  61. $result=sqrt($result1);
  62. $sukses1 = $result;
  63. }
  64. }
  65. ?>
  66. <html>
  67. <h1>Simple Calculation</h1>
  68. <form method="POST" action="">
  69. <table style="border:groove #00FF99">
  70. <tr>
  71. <td style="background-color:aqua; color:red; font-family:'Times New Roman'">Numri i pare</td>
  72. <td><input type="text" name="nr1" /></td>
  73. </tr>
  74. <tr>
  75. <td style="color:burlywood; font-family:'Times New Roman'">Select Operator</td>
  76. <td>
  77. <select name="operator" style="width: 63px">
  78. <option>+</option>
  79. <option>-</option>
  80. <option>*</option>
  81. <option>/</option>
  82. <option>v</option>
  83. </select>
  84. </td>
  85. </tr>
  86. <?php if($operator != v): ?>
  87. <tr>
  88. <td style="background-color:aqua; color:red; font-family:'Times New Roman'">Numri i dyte</td>
  89. <td class="auto-style5">
  90. <input type="text" name="nr2" /></td>
  91. </tr><?php endif; ?>
  92. <tr>
  93. <td></td>
  94. <td><input type="submit" name="submit" /></td>
  95. </tr>
  96. <tr>
  97. <td style="background-color:aqua;color:red">Rezultati = </td>
  98. <td style="color:darkblue"><?php if($noerror == 1) echo $sukses; ?></td>
  99. </tr>
  100. </table>
  101. </form>
  102. <h1>Pythagoras Theorem</h1>
  103. <form method="POST" action="">
  104. <table style="border:groove #00FF99">
  105. <tr>
  106. <td> <p><font color="red"> Per te gjetur njeren nga brinjet mos plotesoni kutine</font></p></td>
  107. </tr>
  108. <tr>
  109. <td style="background-color:aqua; color:red; font-family:'Times New Roman'">Hipotenuza</td>
  110. <td><input type="text" name="C" value="<?php if($noerror == 1 && $emptyc == 1) echo $sukses1; elseif($emptyc == 0) echo $C; ?>" /></td>
  111. </tr>
  112. <tr>
  113. <td style="background-color:aqua; color:red; font-family:'Times New Roman'">Brinja A</td>
  114. <td><input type="text" name="A" value="<?php if($noerror == 1 && $emptya == 1) echo $sukses1; elseif($emptya == 0) echo $A; ?>" /></td>
  115. </tr>
  116. <tr>
  117. <td style="background-color:aqua; color:red; font-family:'Times New Roman'">Brinja B</td>
  118. <td class="auto-style5">
  119. <input type="text" name="B" value="<?php if($noerror == 1 && $emptyb == 1) echo $sukses1; elseif($emptyb == 0) echo $B; ?>" /></td>
  120. </tr>
  121. <tr>
  122. <td></td>
  123. <td><input type="submit" name="submit1" value="Gjej!" /></td>
  124. </tr>
  125. </table>
  126. </form></html>

comments powered by Disqus