-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCal.php
More file actions
59 lines (47 loc) · 903 Bytes
/
Copy pathCal.php
File metadata and controls
59 lines (47 loc) · 903 Bytes
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
51
52
53
54
55
56
57
58
59
<html>
<body>
<form>
<input type="text" name="num1" placeholder="first number">
<input type="text" name="num2" placeholder="second number">
<select name="operator">
<option>None</option>
<option>Add</option>
<option>Subtract</option>
<option>Multiply</option>
<option>Divide</option>
<option>Module</option>
</select>
<br>
<br>
<button type="submit" name="submit" value="submit">Calculate</button>
</form>
<p>The answer is:</p>
<?php
if (isset($_GET[ 'submit' ] )){
$number1= $_GET[ 'num1' ];
$number2= $_GET[ 'num2' ];
$operator= $_GET[ 'operator' ];
switch($operator){
case "None":
echo "You need to select a method!";
break;
case "Add":
echo $number1 + $number2;
break;
case "Subtract":
echo $number1 - $number2;
break;
case "Multiply":
echo $number1 * $number2;
break;
case "Divide":
echo $number1 / $number2;
break;
case "Module":
echo $number1 % $number2;
break;
}
}
?>
</body>
</html>