Advertisement
HoneyRemedy

Untitled

Sep 16th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <h1 style="font-size: 90;text-align: center;color:#b254b9"><i>A Normal Calculator</i><h1>
  4.     </head>
  5.     <body style="background-image:url('arry.jpg') ">
  6.         <form action ='' method="get">
  7.         <table style="background-color: #ffc433; margin: 0 450px; 0 0">
  8.  
  9.     <tr>
  10.         <td style="font-size: 19"><li style="color: white">Enter your number:</li></td>
  11.         <td><input type="number" name="number1" placeholder="Enter your number"></td>
  12.         <br/>
  13.     </tr>
  14.     <tr>
  15.         <td style="font-size: 19"><li style="color: white">Enter your number:</li></td>
  16.         <td><input type="number" name="number2" placeholder="Enter your numbers"></td>
  17.     </tr>
  18.  
  19.         </table>
  20.             <table style="background-color: #ea64e8; margin:0 660px; 0; 0">
  21.         <tr>
  22.             <td>
  23.             <select name="value">
  24.             <option value="sum">+</option>
  25.             <option value="sub">-</option>
  26.             <option value="mul">*</option>
  27.             <option value="div">/</option>
  28.             </select>
  29.             </td>
  30.             <td>
  31.                 <input type="submit" name='submit' value="calculation">
  32.             </td>
  33.         </tr>
  34.             </table>
  35.             <div style="margin:0 635px; 0 0">
  36.                 <input type="text" value="<?php echo cal(); ?>" placeholder="result">
  37.             </div>
  38.         </form>
  39.     </body>
  40. </htmal>
  41.  
  42. <!--########## PHP Starts ###########-->
  43.  
  44. <?php
  45.  
  46.     function cal()
  47.     {
  48.        
  49.         if (isset($_GET['submit']))
  50.         {
  51.    
  52.             $bd= array
  53.                     (
  54.                         $_GET['number1'],
  55.                         $_GET['number2'],
  56.                         $_GET['value'],
  57.                         $result= ''
  58.                     );
  59.        
  60.             if ($bd[2]=='sum')
  61.             {
  62.                 $bd[3]=$bd[0]+$bd[1];
  63.             }
  64.             elseif ($bd[2]=='sub')
  65.             {
  66.                 $bd[3]=$bd[0]-$bd[1];
  67.             }
  68.             elseif ($bd[2]=='mul')
  69.             {
  70.                 $bd[3]=$bd[0]*$bd[1];
  71.             }
  72.             elseif ($bd[2]=='div')
  73.             {
  74.                 $bd[3]=$bd[0]/$bd[1];
  75.             }
  76.             if ($bd[0]=='' OR $bd[1]=='')
  77.             {
  78.                 return "please enter data";
  79.             }
  80.             return $bd[3];
  81.         }
  82.  
  83.         return "please calculation";
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement