Advertisement
indukai1

Rumus

Apr 3rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>Rumus</title>
  5. </head>
  6. <body>
  7.     <form action="" method="POST">
  8.    
  9.         <input type="text" name="luas" placeholer="Luas">
  10.         <br>
  11.         <input type="text" name="keliling" placeholer="Keliling">
  12.         <br>
  13.         <input type="submit" name="hasil" value="Hasil">
  14.  
  15.     </form>
  16. </body>
  17. </html>
  18.  
  19. <?php
  20. function luas($r,$phi = "3.14"){
  21. $z= $phi*$r*$r;
  22. if ($z<=0) {
  23. $z = "hasil tidak boleh kurang dari 0";
  24. }
  25. return $z;
  26. }
  27. function keliling($r,$phi = "3.14"){
  28. $z= 2*$phi*$r;
  29. if ($z<=0) {
  30. $z = "hasil tidak boleh kurang dari 0";
  31. }
  32. return $z;
  33. }
  34.  
  35. if(isset($_POST['hasil'])
  36. {
  37.     $luas = $_POST['luas'];
  38.     $keliling = $_POST['keliling'];
  39.  
  40.     echo "luas = ".luas($luas)."<br>";
  41.     echo "keliling = ".keliling($keliling)."<br>";
  42.  
  43. }
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement