<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>PHP Course</title>
</head>
<style>
h1{
color:teal;
font-weight: bold;
}
.container{
width:400px;
background-color: aqua;
padding: 10px;
}
.first input{
display: block;
}
.answer{
border: 1px solid teal;
padding: 10px;
font-size: 16px;
width:170px;
margin-top: 10px;
text-align: center;
background: #f0f0f0;
}
.number{
padding:10px;
font-size: 15px;
}
.btn{
margin-top: 10px;
padding: 10px;
text-align: center;
font-size: 14px;
background: green;
outline: none;
width: 100px;
margin: auto;
border: none;
}
</style>
<body>
<center>
<form action="index.php" method="post">
<h1>Calculator</h1>
<div class="container">
<div class="first input">
<label>FIRST NUMBER</label>
<input type="number" name="num1" required class="number">
</div>
<div class="first input">
<label>Select Operator</label>
<input type="text" name="op" class="number" required>
</div>
<div class="first input">
<label>SECOND NUMBER</label>
<input type="number" name="num2" required class="number">
</div>
<br>
<button class="btn" type="submit">=</button>
<button class="btn" onclick="reset()" type="reset">delete</button>
<div class="answer">
<?php
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$op=$_POST['op'];
echo "the answer of $num1 $op $num2 is<br><br> <b>";
switch($op){
case "+":
echo $num1+$num2;
break;
case"-":
echo $num1-$num2;
break;
case"*":
echo $num1*$num2;
break;
case"/":
echo $num1/$num2;
break;
case"%":
echo $num1%$num2;
break;
case"**":
echo $num1**$num2;
break;
}
?>
</div>
</div>
</form>
</center>
<footer>
<p style="font-size:20px; background:radial-gradient(blue, red); color:white; font-weight:bolder; text-align:center;">Designed by Richy Tech</p>
</footer>
</body>
</html>
- Blogger Comment
- Facebook Comment
Subscribe to:
Post Comments
(
Atom
)
0 comments:
Post a Comment