-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcalculator.php
73 lines (60 loc) · 2.34 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="icon" href="/image/favicon.png" type="image/png">
<title>Calculator Design With PHP</title>
<meta name="description" content="Third Generation Website<">
<meta name="keywords" content="HTML, CSS, JavaScript,JQUERY,PHP">
<meta name="author" content="Rahat Ahmed">
<!-- Mobile Specific Metas
Mobile Specific Metas
================================================== -->
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php include 'style.php'?>
</head>
<body>
<div class="hasan">
<form action="" method="POST" >
<input type="number" name="firstNumber" class="inputfield" placeholder="First Number">
<input type="number" name="lastNumber" class="inputfield" placeholder="Last Number"> <br>
<div class="selectionAction">
<select name="operation">
<option value="Add">Adition</option>
<option value="Sub">Subtraction</option>
<option value="Multi">Multiplication</option>
<option value="div">Divition</option>
</select>
</div>
<input type="submit" name="submit" value="submit" >
</form>
<?php
if (isset($_POST['submit'])) {
$firstNumber = $_POST['firstNumber'];
$lastNumber = $_POST['lastNumber'];
// echo "$firstNumber . $lastNumber";
$operation = $_POST['operation'];
switch ($operation) {
case 'Add': $sum = $firstNumber + $lastNumber;
echo "The addition of two number is $sum";
break;
case 'Sub': $sub = $firstNumber - $lastNumber;
echo "The Substraction of two number is $sub";
break;
case 'Multi': $multi = $firstNumber * $lastNumber;
echo "The Multiplication of two number is {$multi}";
break;
case 'div': $div = $firstNumber / $lastNumber;
echo "The divition of two number is {$div}";
break;
default:echo "Sorry it is not exist";
}
}
?>
</div>
</body>
</html>