Advertisement
Yaiko

Calculadora/Calculatora | PHP

Feb 19th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['igual'])) {
  3.     $NU = (int) $_POST['NU'];
  4.     $ND = (int) $_POST['ND'];
  5.     $SA = $_POST['SA'];
  6.  
  7.     if ($SA == "+") {
  8.         $RS = $NU+$ND;
  9.     }
  10.     if ($SA == "-") {
  11.         $RS = $NU-$ND;
  12.     }
  13.     if ($SA == "/") {
  14.         $RS = $NU/$ND;
  15.     }
  16.     if ($SA == "*") {
  17.         $RS = $NU*$ND;
  18.     }
  19. }
  20. error_reporting(0);
  21. ?>
  22. <!-- Author: Yaiko; Date: 19/02/15 -->
  23. <!DOCTYPE html>
  24. <html lang="CO">
  25. <head>
  26.     <title>Calculadora</title>
  27.     <meta charset="utf-8">
  28. </head>
  29. <body>
  30.     <center>
  31.         <h1>Mini - Calculadora</h1>
  32.         <form method="POST">
  33.             <fieldset style="width:200px;">
  34.                 <input type="text" name="NU" style="width:50px;" placeholder="#1">
  35.                 <select name="SA">
  36.                     <option value="+">+</option>
  37.                     <option value="-">-</option>
  38.                     <option value="/">/</option>
  39.                     <option value="*">*</option>
  40.                 </select>
  41.                 <input type="text" name="ND" style="width:50px;" placeholder="#2">
  42.                 <input type="submit" name="igual" value="=">
  43.                 <?php echo $RS; ?>
  44.             </fieldset>
  45.         </form>
  46.         <h6>Learn the basics of the advanced</h6>
  47.         <h5>By <b><a href="http://twitter.com/El_Yaiko" target="_blank">Yaiko</a></b></h5>
  48.     </center>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement