Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("functions.php");
- if (isset($_POST["calc"])){ // natisnat li e submit
- // read values from inputs
- $fn = $_POST["num1"];
- $sn = $_POST["num2"];
- $op = $_POST["operation"];
- if (is_numeric($fn) && is_numeric($sn)){
- switch ($op)
- {
- case "+": $result = sum($fn, $sn); break;
- case "-": $result = $fn - $sn; break;
- case "*": $result = $fn * $sn; break;
- case "/":
- if ($sn == 0){
- $result = "Второто ти число е 0!";
- } else {
- $result = $fn / $sn;
- }
- break;
- }
- } else {
- $result = "Не си въвел числа!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement