Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4. $first = $_POST['first'];
  5. $second = $_POST['second'];
  6. $operation = $_POST['operation'];
  7. include("calcFunctions.php");
  8.  
  9.  
  10.     print("<fieldset><h1> We have");
  11.  
  12. if (!is_numeric($first) or !is_numeric($second))
  13. {
  14.     print("<h2> Error one or more inputs are not numbers</h2>");
  15.     #echo("<a href="calculator.html"></a>");
  16. }
  17.  
  18. if($first < 0 or $second < 0)
  19. {
  20.     print("<h1> Error one of more of your numbers is a negative</h1>");
  21.     #echo("<a href = "calculator.html"></a>");
  22. }
  23.  
  24. if (empty($first) or empty($second))
  25. {
  26.     print("<p> One or more input field is empty </p>");
  27.     #echo("<a href="calculator.html"></a>");
  28. }
  29.  
  30.  
  31. if($operation == "Addition")
  32. {
  33.     print("<h1>ADDED up your result</h1>");
  34.  
  35.     $sum = getSum($first, $second);
  36.     echo("$sum");
  37. }
  38. if($operation == "Subtraction")
  39. {
  40.     print("<h1>SUBTRACTED your results</h1>");
  41.     $dif = getDif($first, $second);
  42.     echo("$dif");
  43.  
  44. }
  45. if($operation == "Multiplication")
  46. {
  47.     print("<h1>MULTIPLIED your results</h1>");
  48.     $product = getProd($first, $second);
  49.     echo("$product");
  50. }
  51. if($operation == "Division")
  52. {
  53.     print("<h1>DIVIDED your result</h1>");
  54.     $div = getDiv($first, $second);
  55.     echo("$div");
  56. }
  57. if($operation == "Min")
  58. {
  59.     print("<h1>Found the MIN of the two numbers</h1>");
  60.     $min = getMin($first, $second);
  61.     echo("$min");
  62. }
  63. if($operation == "Max")
  64. {
  65.     print("<h1>Found the MAX of the two numbers</h1>");
  66.     $max = getMax($first, $second);
  67.     echo("$max");
  68. }
  69. print("</fieldset>");
  70. $logFile = 'calculating.dat';
  71. $logFile = fopen("calculating.dat", "a");
  72. $log = $first.$second.$operation;
  73. fwrite($logFile, $log);
  74. $newLog = $log."\n";
  75. fwrite($logFile, $newLog);
  76. fclose($logFile);
  77.  
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement