Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <html>
  2. <input type="submit" name="dodaj(1)" value="1" />
  3. <input type="submit" name="dodaj(2)" value="2" />
  4. <input type="submit" name="3" value="3" /></br>
  5. <input type="submit" name="4" value="4" />
  6. <input type="submit" name="5" value="5" />
  7. <input type="submit" name="6" value="6" /></br>
  8. <input type="submit" name="7" value="7" />
  9. <input type="submit" name="8" value="8" />
  10. <input type="submit" name="9" value="9" /></br>
  11. <input type="submit" name="+" value="+" />
  12. <input type="submit" name="-" value="-" />
  13. <input type="submit" name="*" value="*" />
  14. <input type="submit" name="/" value="/" />
  15.  
  16.  
  17. <form action="" method="POST" >
  18. <input type="text" name="oblicz" id="oblicz" /></br>
  19. <input type="submit" value="Policz" />
  20. </form>
  21.  
  22.  
  23. <script>
  24. function dodaj(
  25. var element = document.getElementById("demo");
  26.  
  27.  
  28. </script>
  29.  
  30.  
  31. <?php
  32. function calculate_string( $mathString ) {
  33. $mathString = trim($mathString); // biale znaki
  34. $mathString = preg_replace('[^0-9\+-\*\/\(\) ]', '', $mathString);
  35. // usun operatora
  36. $compute = create_function("", "return (" . $mathString . ");" );
  37. return 0 + $compute();
  38. }
  39.  
  40. $string = $_POST['oblicz'];
  41. echo calculate_string($string);
  42.  
  43. ?>
  44.  
  45. <html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement