-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
105 lines (77 loc) · 1.88 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Php Calculator</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<h1 class="title"><script src="js.js"></script></h1>
<div class="input">
<form>
<input type="number" name="number1" placeholder="1st value" class="inputfield">
<select name="select" class="selectbtn" >
<option>None</option>
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select>
<input type="number" placeholder="2nd value" name="number2" class="inputfield">
<div class="btn">
<button type="submit" name="submit" value="submit" class="selectbtn" >Submit</button>
<input type="reset" value="Reset" class="selectbtn">
</div>
</form>
<p class="para">Your Answer is:</p>
<div class="calculator">
<?php
if (isset($_GET['submit'])){
$result1 = $_GET['number1'];
$result2 = $_GET['number2'];
$select = $_GET['select'];
switch ($select){
case "+":
echo $result1 + $result2;
break;
case "-":
echo $result1 - $result2;
break;
case "*":
echo $result1 * $result2;
break;
case "/":
echo $result1 / $result2;
break;
};
if ($result1 < $result2){
echo "<br>
$result1 smaller than $result2 ";
}
if ($result1 > $result2){
echo "<br>
$result1 bigger than $result2 ";
}
if ($result1 == $result2){
echo "<br>
$result1 and $result2 are equal ";
}
if (empty($result1)){
echo "<br>
1st Field Is Empty";
}
if (empty($result2)){
echo "<br>
2nd Field Is Empty"; }
}
?>
</div>
<footer class="footer">
<hr>
<font>Developed By
<a href="https://facebook.com/nabeel.goraya" target="_blank">Nabeel Goraya</a>
</font>
<hr>
</footer>
</body>
</html>