-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
50 lines (43 loc) · 1.14 KB
/
index.php
File metadata and controls
50 lines (43 loc) · 1.14 KB
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
43
44
45
46
47
48
49
50
<?php
include 'headerNav.php';
?>
<form>
<input type="text" name="num1" placeholder="Number 1">
<input type="text" name="num2" placeholder="Number 2">
<select name="operation">
<option>None</option>
<option>Add</option>
<option>Subtract</option>
<option>Multiply</option>
<option>Divide</option>
</select>
<br>
<button type="submit" name="submit" value="submit">Calculate</button>
</form>
<p> The answer is: </p>
<?php
if (isset($_GET['submit'])) {
$result1 = $_GET['num1'];
$result2 = $_GET['num2'];
$operator = $_GET['operation'];
switch ($operator) {
case "None":
echo "Need to select operator";
break;
case "Add":
echo $result1 + $result2;
break;
case "Subtract":
echo $result1 - $result2;
break;
case "Multiply":
echo $result1 * $result2;
break;
case "Divide":
echo $result1 / $result2;
break;
}
}
?>
</body>
</html>