-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.php
52 lines (32 loc) · 1.36 KB
/
calculator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
session_start();
include "function.php";
if (isset($_POST['numberOne']) && isset($_POST['numberTwo']))
$numberOne = $_POST['numberOne'];
$numberTwo = $_POST['numberTwo'];
if (isset($_POST['a']) && isset($_POST['b']) && isset($_POST['c']))
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
switch (true) {
case isset($_POST['add']):
$_SESSION['add_result'] = numbersAddition($numberOne,$numberTwo);
header('Location: http://localhost/alga/calculator/index.php');
break;
case isset($_POST['sub']):
$_SESSION['sub_result'] = numbersSubtraction($numberOne,$numberTwo);
header('Location: http://localhost/alga/calculator/index.php');
break;
case isset($_POST['multi']):
$_SESSION['multi_result'] = numbersMultiplication($numberOne,$numberTwo);
header('Location: http://localhost/alga/calculator/index.php');
break;
case isset($_POST['divide']);
$_SESSION['divide_result'] = numbersDivide($numberOne,$numberTwo);
header('Location: http://localhost/alga/calculator/index.php');
break;
case isset($_POST['quad']);
$_SESSION['quad_result'] = quadraticEquationSolver($a, $b, $c);
header('Location: http://localhost/alga/calculator/index.php');
break;
}