mathiaspl20

calc

Jun 6th, 2016
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="de">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>dEn Cliqulatoz</title>
  6. <h1>THe KLaCULATIOR</h1>
  7. </head>
  8. <body bgcolor="#FF00FF" background="http://bestanimations.com/Animals/Birds/Parrots/animated-parrot-gif-2.gif">
  9.  
  10.     <form action="" method="Post">
  11. <p>z1 Value:<br/>
  12.         <input type="text" name="z1" value="<?PHP if(!empty($_POST['z1']))echo $_POST['z1']?>"><br><br>
  13. <p>z2 Value:<br/>
  14.         <input type="text" name="z2" value="<?PHP if(!empty($_POST['z2']))echo $_POST['z2']?>">
  15.         <br><br>
  16.        
  17. <button type="submit" name="group1" id="add" value="add">+</button>
  18. <button type="submit" name="group1" id="subtract" value="subtract">-</button>
  19. <button type="submit" name="group1" id="times" value="times">*</button>
  20. <button type="submit" name="group1" id="divide" value="divide">/</button>
  21. <p>
  22. <button type="submit" name="group1" id="force" value="force">^</button>
  23. <button type="submit" name="group1" id="sqrt" value="sqrt">²√</button>
  24. <!-- <button type="submit" name="group1" id="xrt" value="divide">/</button>
  25.  <button type="submit" name="group1" id="divide" value="divide">/</button> -->
  26.  
  27.     </form>
  28.  
  29.  
  30. <p>
  31. answer:
  32. <p>
  33. <h1>
  34. <?php
  35. /*
  36. if (!empty($_POST['z1'])){
  37. $z1 = $_POST['z1'];
  38. $z2 = $_POST['z2'];
  39. else if($_POST['group1'] == 'sqrt') {
  40. echo sqrt($z1);
  41. }
  42. else if(!empty($_POST['z1']) && !empty($_POST['z2'])){
  43.  
  44. $z1 = $_POST['z1'];
  45. $z2 = $_POST['z2'];
  46. if($_POST['group1'] == 'add') {
  47. echo $z1 + $z2;
  48. }
  49. else if($_POST['group1'] == 'subtract') {
  50. echo $z1 - $z2;
  51. }
  52. else if($_POST['group1'] == 'times') {
  53. echo $z1 * $z2;
  54. }
  55. else if($_POST['group1'] == 'divide') {
  56. echo $z1 / $z2;
  57. }
  58. else if($_POST['group1'] == 'force') {
  59. echo pow($z1 , $z2);
  60. }
  61. }
  62. }
  63. else{}
  64. */
  65. if(!empty($_POST['z1']) && !empty($_POST['z2'])){
  66. switch($_POST["group1"]){
  67.     case "add":
  68.         echo ($z1 + $z2);
  69.         break;
  70.     case "subtract":
  71.         echo ($z1 - $z2);
  72.         break;
  73.     case "times":
  74.         echo ($z1 * $z2);
  75.         break;
  76.     case "divide":
  77.         echo ($z1 / $z2);
  78.         break;
  79.     case "force":
  80.         echo (pow($z1, $z2));
  81.         break;
  82.     case "sqrt":
  83.         echo (sqrt($z1));
  84.         break;
  85. //  case(){$z1 $z2}
  86. //  case(){$z1 $z2}
  87.    
  88. }}
  89. else{}
  90. ?>
  91.  
  92. </h1>
  93. </form>
  94. </body>
  95. </html>
RAW Paste Data