Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php
- $first = $_POST['first'];
- $second = $_POST['second'];
- $operation = $_POST['operation'];
- include("calcFunctions.php");
- print("<fieldset><h1> We have");
- if (!is_numeric($first) or !is_numeric($second))
- {
- print("<h2> Error one or more inputs are not numbers</h2>");
- #echo("<a href="calculator.html"></a>");
- }
- if($first < 0 or $second < 0)
- {
- print("<h1> Error one of more of your numbers is a negative</h1>");
- #echo("<a href = "calculator.html"></a>");
- }
- if (empty($first) or empty($second))
- {
- print("<p> One or more input field is empty </p>");
- #echo("<a href="calculator.html"></a>");
- }
- if($operation == "Addition")
- {
- print("<h1>ADDED up your result</h1>");
- $sum = getSum($first, $second);
- echo("$sum");
- }
- if($operation == "Subtraction")
- {
- print("<h1>SUBTRACTED your results</h1>");
- $dif = getDif($first, $second);
- echo("$dif");
- }
- if($operation == "Multiplication")
- {
- print("<h1>MULTIPLIED your results</h1>");
- $product = getProd($first, $second);
- echo("$product");
- }
- if($operation == "Division")
- {
- print("<h1>DIVIDED your result</h1>");
- $div = getDiv($first, $second);
- echo("$div");
- }
- if($operation == "Min")
- {
- print("<h1>Found the MIN of the two numbers</h1>");
- $min = getMin($first, $second);
- echo("$min");
- }
- if($operation == "Max")
- {
- print("<h1>Found the MAX of the two numbers</h1>");
- $max = getMax($first, $second);
- echo("$max");
- }
- print("</fieldset>");
- $logFile = 'calculating.dat';
- $logFile = fopen("calculating.dat", "a");
- $log = $first.$second.$operation;
- fwrite($logFile, $log);
- $newLog = $log."\n";
- fwrite($logFile, $newLog);
- fclose($logFile);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement