Advertisement
dysphafiz_

Untitled

Oct 29th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Kasus 3</title>
  5.     <style type="text/css">
  6.         body{
  7.             background-color: yellow;
  8.         }
  9.         input[type="text"]{
  10.             border-radius: 4px;
  11.             background-color: silver;
  12.         }
  13.         input[type="text"]:focus{
  14.             background-color: white;
  15.             transition: 0.5s;
  16.         }
  17.         input.button{
  18.             color: black;
  19.             background: orange;
  20.             border: 2px #191919 outset;
  21.             padding: 5px 20px;
  22.             font-size: 14px;
  23.             transition: 0.4s;
  24.             border-radius: 6px;
  25.         }
  26.         input.button:hover{
  27.             color: orange;
  28.             background: #191919;
  29.             background: black;
  30.            
  31.         }
  32.     </style>
  33. </head>
  34. <body>
  35.     <h1>Hitung Jumlah Huruf</h1>
  36.     <form name="" id="" method="post" action="">
  37.         <p>Masukkan Kalimat
  38.             <input type="text" name="kalimat" autocomplete="off">
  39.             <input type="radio" name="huruf" value="a">a
  40.             <input type="radio" name="huruf" value="i">i
  41.             <input type="radio" name="huruf" value="u">u
  42.             <input type="radio" name="huruf" value="e">e
  43.             <input type="radio" name="huruf" value="o">o
  44.             <input class="button" type="submit" name="submit" value="Hitung">
  45.         </p>
  46.    
  47.     <?php
  48.         $kalimat = $_POST['kalimat'];
  49.         $huruf = $_POST['huruf'];
  50.         $a=0;
  51.         $jumlah=0;
  52.  
  53.         while ($a <= strlen($kalimat)) {
  54.             if ($kalimat[$a] == $huruf) {
  55.                 $jumlah++;
  56.             }
  57.             $a++;
  58.         }
  59.     ?>
  60.     <?php
  61.         echo "<p>Jumlah Huruf '$huruf' pada kalimat '$kalimat' adalah $jumlah</p>";
  62.     ?>
  63.     </form>
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement