Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document
- </title>
- <title>Simple Calculator Program in PHP - Tutorials Class
- </title>
- </head>
- <div class="bg">
- </div>
- <div id="calc-cart" class="bg bg2">
- </div>
- <div id= "layer 3"class="bg bg3">
- </div>
- <style>
- h2 {
- color: #970000;
- font-family:Arial!important;
- }
- b {
- font-family: arial;
- }
- #calc-cart {
- background-color: bisque;
- display: grid;
- }
- .inputs {
- box-shadow:inset 0px -6px 20px 1px #a4e271;
- background:linear-gradient(to bottom, #89c403 5%, #77a809 100%);
- background-color:#89c403;
- border-radius:33px;
- display:inline-block;
- cursor:pointer;
- color:#ffffff;
- font-family:Arial!important;
- font-size:21px;
- font-weight:bold;
- font-style:italic;
- padding:11px 24px;
- text-decoration:none;
- text-shadow:0px 3px 0px #528009;
- }
- .inputs:hover {
- background:linear-gradient(to bottom, #77a809 5%, #89c403 100%);
- background-color:#77a809;
- }
- .inputs:active {
- position:relative;
- top:1px;
- }
- html {
- height:100%;
- }
- body {
- margin:0;
- }
- .bg {
- animation: slide 3s cubic-bezier(.99,.05,.12,1.02) infinite alternate;
- background-image: linear-gradient(-45deg, #cca633 50%, #ac5845 50%);
- bottom:0;
- left:-50%;
- opacity:.5;
- position:fixed;
- right:-50%;
- top:0;
- z-index:-1;
- }
- .bg2 {
- animation-direction:alternate-reverse;
- animation-duration:4s;
- }
- .bg3 {
- animation-duration:5s;
- }
- .content {
- background-color:rgba(255,255,255,.8);
- border-radius: 18%;
- box-shadow: rgba(255, 255, 255, 0.1) 0px 1px 1px 0px inset, rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px;
- box-sizing:border-box;
- left:50%;
- padding:10vmin;
- position:fixed;
- text-align:center;
- top:50%;
- transform:translate(-50%, -50%);
- }
- h3 {
- font-family:Arial, Helvetica, sans-serif;
- }
- @keyframes slide {
- 0% {
- transform:translateX(-25%);
- }
- 100% {
- transform:translateX(25%);
- }
- }
- /* Inline #1 | https://localhost//phpstuff/calci2.php */
- </style>
- <?php
- $first_number = $_POST['first_number'];
- $second_number = $_POST['second_number'];
- $operator = $_POST['operator'];
- $result = '';
- if (is_numeric($first_number) && is_numeric($second_number)) {
- switch ($operator) {
- case "Add":
- $result = $first_number + $second_number;
- break;
- case "Subtract":
- $result = $first_number - $second_number;
- break;
- case "Multiply":
- $result = $first_number * $second_number;
- break;
- case "Divide":
- $result = $first_number / $second_number;
- }
- }
- ?>
- <body>
- <div class="content">
- <h2 style = "font-size:30px;">PHP - Simple Calculator Program</h2>
- <form action="" method="post" id="calc-form">
- <p>
- <input type="number" name="first_number" id="first_number" required="required" value="<?php echo $first_number; ?>" /> <b>First Number</b>
- </p>
- <p>
- <input type="number" name="second_number" id="second_number" required="required" value="<?php echo $second_number; ?>" /> <b>Second Number</b>
- </p>
- <p>
- <input readonly="readonly" name="result" value="<?php echo $result; ?>"> <b>Result</b>
- </p>
- <input type="submit" name="operator" value="Add" class="inputs" />
- <input type="submit" name="operator" value="Subtract" class="inputs"/>
- <input type="submit" name="operator" value="Multiply" class="inputs"/>
- <input type="submit" name="operator" value="Divide" class="inputs"/>
- </form>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment