Advertisement
dysphafiz_

Untitled

Oct 2nd, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.17 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Kasus 3 (M. Hafidz Fadillah - XI RPL 2)</title>
  5.     <style type="text/css">
  6.         body{
  7.             background-color: blanchedalmond;
  8.         }
  9.         input.button{
  10.             color: black;
  11.             background: white;
  12.             border: 2px darkgray outset;
  13.             padding: 5px 20px;
  14.             font-size: 14px;
  15.         }
  16.         input.button:hover{
  17.             color: white;
  18.             background: black;
  19.         }
  20.     </style>
  21. </head>
  22. <body>
  23.     <h1>Hitung Jumlah Huruf</h1>
  24.     <form name="" id="" method="post" action="">
  25.         <p>Masukkan Kalimat
  26.             <input type="text" name="kalimat">
  27.             <input type="radio" name="huruf" value="a">a
  28.             <input type="radio" name="huruf" value="i">i
  29.             <input type="radio" name="huruf" value="u">u
  30.             <input type="radio" name="huruf" value="e">e
  31.             <input type="radio" name="huruf" value="o">o
  32.             <input class="button" type="submit" name="submit" value="Hitung">
  33.         </p>
  34.    
  35.     <?php
  36.         $kalimat = $_POST['kalimat'];
  37.         $huruf = $_POST['huruf'];
  38.         $a=0;
  39.         $jumlah=0;
  40.  
  41.         while ($a <= strlen($kalimat)) {
  42.             if ($kalimat[$a] == $huruf) {
  43.                 $jumlah++;
  44.             }
  45.             $a++;
  46.         }
  47.     ?>
  48.     <?php
  49.         echo "<p>Jumlah Huruf '$huruf' pada kalimat '$kalimat' adalah $jumlah</p>";
  50.     ?>
  51.     </form>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement