Latest Stories

Free space marked as "Unusable"


Pernahkah saat installasi dual boot Ubuntu muncul warning seperti ini? Hal ini di sebabkan oleh 4 partisi harddisk yang digunakan adalah jenis primary. Solusi permasalahan ini adalah mengubah salah satu harddisk menjadi logical. Beberapa software telah mendukung hal ini seperti partition magic atau Easus Partition Master.

Silahkan tinggalkan komentar jika ada hal yg ingin ditanyakan


Read More ...

Latest Stories

Praktikum 7.1


     Ketik kode  berikut dan simpan dengan nama login.php pada root direktori web server.

     <?php
    session_start();
  
    if ( isset( $_POST["login"]) ) {
        login();
    } elseif ( isset ( $_GET["action"]) and $_GET["action"] == "logout") {
        logout();
    }elseif ( isset ( $_SESSION["username"])) {
        displayPage();
    }else{
        displayLoginForm();
    }
  
    function login(){
        $username = "ulfa";
        $passwd = "fha";
      
        if (isset ( $_POST["username"]) and isset ($_POST["password"])) {
            echo $_POST ["username"];
            if ($_POST["username"] == $username and $_POST["password"] == $passwd ){
                $_SESSION["username"] = $username;
                session_write_close();
                header("Location : login.php");
                }else{
                    displayLoginForm ("username/password Tidak cocok");
                }
            }
        }
        function logout(){
            unset($_SESSION["username"]);
            session_write_close();
            header("Location: login.php");
        }
        function displayPage(){
            displayPageHeader();
        ?>
      
        <p>Welcome, <strong><?php echo $SESSION["username"] ?></strong> Anda sudah Berhasil Login.</p>
        <p><a href="login.php?action=logout">Logout</a></p>
        </body>
        </html>
      
        <?php
        }
        function displayLoginForm($message=""){
            displayPageHeader();
        ?>
      
        <?php if($message)
        echo '<p class="error">' . $message . '</p>';
        ?>
       <center>
        <form action="login.php" method="post">
       
            <div style= "width: 30em;">
            <label for = "username">Username</label>
            <input type="text" name="username" id="username" value=""/><br>
            <label for="password">Password</label>
            <input type="password" name="password" id="password" value=""/>
            <div style="clear: both;">
            <input type="submit" name="login" value="Login" />
            </div>
            </div>
        </center>
        </form>
        </body>
        </html>
        <?php
        }
      
        function displayPageHeader(){
        ?>
      
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

        <head>
            <title> A Login Form</title>
            <link rel="stylesheet" type="text/css" href="common.css" />
            <style type="text/css">
            .error{ background: #d33; color: white; padding: 0.2em; }
            </style>
        </head>
        <body>
        <h1>Silahkan Login</h1>
        <?php
        }
        ?>


Ketik kode berikut dan simpan dengan nama common.css pada root direktori web server


/*Page Body */
body {font-family : Arial,helvetia,sans-serif;}
/*definition lists*/
dl {
width:100%;
margin:2em 0;
padding: 0;
clear: both;
overflow:auto;
}
dt {
width:30%;
float : left ;
margin:0;
padding: 5px 9.9% 5px 0; 0
order-top:1px solid #DDDDB7;
font-weight:bold;
overflow:auto;
clear:left;
}
dd {
width : 60%;
float :left;
margin:0;
padding:6px 0 5px 0;
border-top:1px solid #DDDDB7;
overflow:auto;
}
/*headings*/
h1{
font-weight:bold;
margin:35px 0 14px;
color:#666;
font-size:1.5em;
}
h2{
font-weight:bold;
margin:30px 0 12px;
color:#666;
font-size:1.3em;
}
h3{
font-weight:normal;
margin:30px 0 12px;
color:#666;
font-size:1.2em;
}
h4{
font-weight:bold;
margin:25px 0 12px;
color:#666;
font-size:1.0em;
}
h5{
font-weight:bold;
margin:25px 0 12px;
color:#666;
font-size:0.9em;
}
/*form*/
label { display:block;
float:left;
clear:both;
text-align:right;
margin:0.6em 5px 0 0;
width: 40%;
}
input,select,textarea {
float:right;
margin:1em 0 0 0;
width:57%;
}
input {
border:1px solid #666;
}
input[type=radio], iinput[type=checkbox],input[type=submit],input[type=reset],input[type=button],input[type=image]{
width:auto;
}


GAMBAR :







Maka saat user mengklik Login yang akan muncul adalah :







Jika user salah mengisi password maka yang akan muncul adalah sbg berikut :







Read More ...

Latest Stories

  • Praktikum 5.1 Array Satu Dimensi


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
        <?php
            //membuat array
            $mahasiswa = array("Toni","Joko","Agam","Tina","Lia","Yana");
            $ipk = array(3.23,2.89,4.00,3.12,2.67,2.22);
            $i = 0;
            //mengakses array
            echo "<table border  = 1>";
            echo "<tr>";
            echo "<td>No</td>";
            echo "<td>Nama</td>";
            echo "<td>ipk</td>";
            echo "</tr>";
            while ($nama = each ($mahasiswa)){
                echo "<tr>";
                $no = $nama[0] + 1;
                echo "<td>$no</td>";
                echo "<td>$nama[1]</td>";
                echo "<td>$ipk[$i]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        ?>
</body>
</html>


GAMBAR :







Praktikum 5.2 Array Multi-Dimensi



<head>
    <tittle>Praktikum 5 Array</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
        <?php
            //membuat array
            $mahasiswa = array (
array(
"nama" =>"Toni",
"nim" => "123456789",
"IPK" => 2.79
),

array (
"nama"  => "Joko",
"nim" => "234567890",
"IPK" => 2.67
),

array  (
"nama" => "Tina",
"nim" => "4567890145",
"IPK" => 2.34
),

array (
"nama" => "Lia",
"nim" => "6789043256",
"IPK" => 3.12
),

array (
"nama" => "Agam",
"nim" => "67452253436",
"IPK" => 4.00
),

array (
"nama" => "Yanna",
"nim" => "345562327844",
"IPK" => 3.56
                                          ),
                                );
              echo "<table border=1>";
              echo "<tr>";
              echo "<td>Nama</td>";
              echo "<td>N I M</td>";
              echo "<td>IPK</td>";
              foreach ($mahasiswa as $nama){
                echo "<tr>";
                foreach ($nama as $key =>$value){
                    echo "<td>$value</td>";
                }
                echo "</tr>";
            }
            echo "</table>";
        ?>
</body>
</html>


GAMBAR :






Read More ...

Latest Stories

  • Praktikum 4.1 Percabangan While
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
    <?php
        $tinggi = 10 ;
        $i = 0;
        while ($i < $tinggi){
            $j = 0;      
            while($j<=$i){
                echo "*";
                $j++;
            }
        echo "<br>";
        $i++;  
        }
    ?>
</body>
</html> 

GAMBAR :




















  • Coding di atas diatas sehinnga memiliki output segitiga bawah,maka codenya adalah sebagai berikut :



 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
    <?php
        $tinggi = 0 ;
        $i = 10;
        while ($i >= $tinggi){
            $j = 0;      
            while($j <=$i){
                echo "*";
                $j++;
            }
        echo "<br>";
        $i--;  
        }
    ?>
</body>
</html>


  • Praktikum 4.2 Perulangan Do...While
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
    <?php
        $i=0;
        do {
            $j = 0;
            while($j < $i){
                echo "*";
                $j++;
            }
        echo "<br>";
        $i++;
    }while($i<=10);
    ?>
</body>
</html>

GAMBAR :




  • Ketikan kode berikut dan simpan dengan nama cek-bilangan.php.
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
        <?php
            $x = 100;
            while ($x > 0){
                if ($x % 2 ==0){
                    echo "$x adalah bilangan Genap";
                }else{
                    echo "$x adalah bilangan <b>Ganjil</b>";
                }
                echo "<br>";
                $x--;
            }
        ?>
</body>
</html>

 GAMBAR :





  • Modifikasi code di atas untuk menampilkan 100 baris tulisan,yang mana apabila itu baris ketiga dan kelipatannya akan bertuliskan "foo" dan jika baris kelima dan kelipatannya akan bertuliskan "bar" serta tiap baris ke 15 dan kelipatannya akan bertuliskan "foobar" selain ketentuan ini tulisan yang akan mucul adalah "ini baris ke x."



Maka code nya sebagai berikut :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
        <?php
            $x = 1;
            while ($x < 100){
                if ($x % 15 == 0 ){
                    echo "foobar";
                }else if($x % 5 == 0){
                    echo "bar";  
                }else if($x % 3 == 0){
                    echo "foo";
                }else{
                    echo "ini baris ke-$x";
                }
                echo "<br>";
                $x++;
            }
        ?>
</body>
</html>


  • Praktikum 4.3 Perulangan for
              Gunakan perulangan for unutuk menggantikan code while pada praktikum 4.1 sehingga mendapatkan gambar  segitiga yang sama seperti pada gambar 4.1 & 4.2
                    
        Struktur 1 for (segitiga atas)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
    <?php
        $tinggi = 10;
        $i = 0;
        for ($i = 0 ; $i <= $tinggi ; $i++){
            for ($j = 0 ; $j < $i ; $j++ ){
                echo "*";
            }
                echo "<br>";
        }
    ?>
</body>
</html>

GAMBAR :



   




 Struktur 2 for  (segitiga bawah)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 4.Perulangan</tittle><br><br>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>
<body>
    <?php
        $tinggi = 0;
        $i = 10;
        for ($i = 10 ; $i >= $tinggi ; $i--){
            for ($j = 0 ; $j < $i ; $j++ ){
                echo "*";
            }
                echo "<br>";
        }
    ?>
</body>
</html>

GAMBAR :







Read More ...

Latest Stories

Praktikum 3.1 Percabngan if

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
    $stok_roti = 100;
  
    if($stok_roti <= 50){
        echo '<script language= "javascript"> alert ("Stock Roti sudah menipis")</script>';
        }
    ?>
<body>
</html>

Output :










  • Memunculkan message box jika sudah di bawah 100
       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
    $stok_roti = 50;
  
    if($stok_roti <= 50){
        echo '<script language= "javascript"> alert ("Stock Roti sudah menipis")</script>';
        }
      
        ?>
      
<body>

</html>

Output :


  • membuat stok baju dan celana dan memunculkan peringatan (message box) jika stok sudah di bawah 10.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
    $baju = 9;
    $celana = 9;
    if($baju <= 10 && $celana <= 10){
        echo '<script language= "javascript"> alert ("Stock baju dan celana sudah menipis")</script>';
        }
      
        ?>
      
<body>

</html>
GAMBAR :









  • menentukan sebuah bilangan genap dan ganjil
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN
  "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
    $bil = 3;
  
    if($bil % 2 != 0 ){
        echo '<script language= "javascript"> alert ("3 adalah Bilangan Ganjil")</script>';
        }

        ?>
      
<body>

</html>
GAMBAR :










Praktikum 3.2 Percabangan if...else


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
    $umur = 12;
  
    if (($umur < 20) && ($umur > 10)){
        echo 'Anda masih remaja';
        }
    else {
        echo 'Anda bukan lagi remaja';
    }  
    ?>  
</body>
</html>
GAMBAR :
Praktikum 3.3 Percabangan if...else if...else

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
    $bulan_lahir = 6;
  
    if ($bulan_lahir == 1){
        echo 'Anda lahir di bulan januari';
    }else if ($bulan_lahir == 2){
        echo 'Anda lahir di bulan Februari';
    }else if ($bulan_lahir == 3){
        echo 'Anda lahir di bulan Maret';
    }else if ($bulan_lahir == 4){
        echo 'Anda lahir di bulan April';
    }else if ($bulan_lahir == 5){
        echo 'Anda lahir di bulan Mei';
    }else if ($bulan_lahir == 6){
        echo 'Anda lahir di bulan Juni';
    }else if ($bulan_lahir == 7){
        echo 'Anda lahir di bulan Juli';
    }else if ($bulan_lahir == 8){
        echo 'Anda lahir di bulan Agustus';
    }else if ($bulan_lahir == 9){
        echo 'Anda lahir di bulan September';
    }else if ($bulan_lahir == 10){
        echo 'Anda lahir di bulan Oktober';
    }else if ($bulan_lahir == 11){
        echo 'Anda lahir di bulan November';
    }else if ($bulan_lahir == 12){
        echo 'Anda lahir di bulan Desember';
    }else{
        echo 'Bulan yang anda masukkan salah';
    }
?>
</body>
</html>
GAMBAR :









Praktikum 3.4 Percabangan if bersarang

<html>
<head>
<body>
      <?
 $tanggal_lahir=16;
 $bulan_lahir=6;

 if($bulan_lahir==1){
  if($tanggal_lahir<=20)
     echo "Anda termasuk berzodiak <b>Aquarius</b>";
  else
     echo "Anda bezodiak <b>Aquarius</b>";
        }else if ($bulan_lahir==2){
   if($tanggal_lahir<=19)
     echo "Anda termasuk berzodiak <b>Aquarius</b>";
   else
     echo "Anda bezodiak <b>Pisces</b>";
 }else if ($bulan_lahir==3){
   if($tanggal_lahir<=20)
     echo "Anda termasuk berzodiak <b>Pisces</b>";
   else
     echo "Anda bezodiak <b>Aries</b>";
 }else if ($bulan_lahir==4){
   if($tanggal_lahir<=19)
     echo "Anda termasuk berzodiak <b>Aries</b>";
   else
     echo "Anda bezodiak <b>Taurus</b>";
 }else if ($bulan_lahir==5){
   if($tanggal_lahir<=20)
     echo "Anda termasuk berzodiak <b>Taurus</b>";
   else
     echo "Anda bezodiak <b>Gemini</b>";
 }else if ($bulan_lahir==6){
   if($tanggal_lahir<=21)
     echo "Anda termasuk berzodiak <b>Gemini</b>";
   else
     echo "Anda bezodiak <b>Cancer</b>";
 }else if ($bulan_lahir==7){
   if($tanggal_lahir<=22)
     echo "Anda termasuk berzodiak <b>Cancer</b>";
   else
     echo "Anda bezodiak <b>Leo</b>";
 }else if ($bulan_lahir==8){
   if($tanggal_lahir<=23)
     echo "Anda termasuk berzodiak <b>Leo</b>";
   else
     echo "Anda bezodiak <b>Virgo</b>";
 }else if ($bulan_lahir==9){
   if($tanggal_lahir<=22)
     echo "Anda termasuk berzodiak <b>Virgo</b>";
   else
     echo "Anda bezodiak <b>Libra</b>";
 }else if ($bulan_lahir==10){
   if($tanggal_lahir<=23)
     echo "Anda termasuk berzodiak <b>Libra</b>";
   else
     echo "Anda bezodiak <b>Scorpio</b>";
 }else if ($bulan_lahir==11){
   if($tanggal_lahir<=22)
     echo "Anda termasuk berzodiak <b>Scorpio</b>";
   else
     echo "Anda bezodiak <b>Sagitarius</b>";
 }else if ($bulan_lahir==12){
   if($tanggal_lahir<=21)
     echo "Anda termasuk berzodiak <b>Sagitarius</b>";
   else
     echo "Anda bezodiak <b>Capricon</b>";
 }else{
     echo "Bulan yang anda masukkan <b>salah</b>";
 }
      ?>

</body>
</head>
</html>


GAMBAR :




Praktikum 3.5 Percabangan switch...case

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
        $hari_ini = 'Rabu';
        switch ($hari_ini){
        case 'Senin':
            echo 'Hari Senin';
            break;
        case 'Selasa':
            echo 'Hari Selasa';
            break;
        case 'Rabu':
            echo 'Hari Rabu';
            break;
        case 'Kamis':
            echo 'Hari Kamis';
            break;
        case 'Jumat':
            echo 'Hari jumat';
            break;
        case 'Sabtu':
            echo 'Hari Sabtu';
            break;
        case 'Minggu':
            echo 'Hari Minggu';
            break;
        default:
            echo 'Hari Tidak Terdaftar';
            break;
        }
    ?>
</body>
</html>
GAMBAR :



  • Pada praktikum 3.3 penggunaan if diganti dengan penggunaan switch...case
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">

<head>
    <tittle>Praktikum 3. Struktur Kontrol</tittle>
    <meta http-equiv="content-type" content="text/html; charsct=utf-8" />
    <meta name="generator" content="Geany 0.20" />
</head>

<body>
    <?php
        $bulan_lahir = 6;
        switch ($bulan_lahir){
        case 1:
            echo 'Anda lahir di bulan Januari';
            break;
        case 2:
            echo 'Anda lahir di bulan Februari ';
            break;
        case 3:
            echo 'Anda lahir di bulan Maret';
            break;
        case 4:
            echo 'Anda lahir di bulan April';
            break;
        case 5:
            echo 'Anda lahir di bulan Mei';
            break;
        case 6:
            echo 'Anda lahir di bulan Juni';
            break;
        case 7:
            echo 'Anda lahir di bulan Juli';
            break;
        case 8:
            echo 'Anda lahir di bulan Agustus';
            break;
        case 9:
            echo 'Anda lahir di bulan September';
            break;
        case 10:
            echo 'Anda lahir di bulan Oktober';
            break;
        case 11:
            echo 'Anda lahir di bulan November';
            break;
        case 12:
            echo 'Anda lahir di bulan Desember';
            break;
        default:
            echo 'bulan Tidak Terdaftar';
            break;
        }
    ?>
</body>
</html>
GAMBAR :



   




 Pada Praktikum 3.4 Ubah menjadi switch...case dan if yang di dalam tetap tanpa mengganti apapun..


<html>
<head>
<body>
      <?
 $tanggal_lahir=16;
 $bulan_lahir=6;

switch ($bulan_lahir){
 case '1':
  if($tanggal_lahir<=20){
     echo "Anda termasuk berzodiak <b>Aquarius</b>";
     break;
  }else{
     echo "Anda bezodiak <b>Aquarius</b>";
     break;
  }
        case '2' :
   if($tanggal_lahir<=19){
     echo "Anda termasuk berzodiak <b>Aquarius</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Pisces</b>";
     break;
          }
        case '3' :
   if($tanggal_lahir<=20){
     echo "Anda termasuk berzodiak <b>Pisces</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Aries</b>";
     break;
          }
        case '4' :
   if($tanggal_lahir<=19){
     echo "Anda termasuk berzodiak <b>Aries</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Taurus</b>";
     break;
          }
        case '5' :
   if($tanggal_lahir<=20){
     echo "Anda termasuk berzodiak <b>Taurus</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Gemini</b>";
     break;
          }
        case '6' :
   if($tanggal_lahir<=21){
     echo "Anda termasuk berzodiak <b>Gemini</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Cancer</b>";
     break;
          }
        case '7' :
   if($tanggal_lahir<=22){
     echo "Anda termasuk berzodiak <b>Cancer</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Leo</b>";
     break;
          }
        case '8' :
   if($tanggal_lahir<=23){
     echo "Anda termasuk berzodiak <b>Leo</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Virgo</b>";
     break;
          }
        case '9' :
   if($tanggal_lahir<=22){
     echo "Anda termasuk berzodiak <b>Virgo</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Libra</b>";
     break;
          }
        case '10' :
   if($tanggal_lahir<=23){
     echo "Anda termasuk berzodiak <b>Libra</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Scorpio</b>";
     break;
          }
        case '11' :
   if($tanggal_lahir<=22){
     echo "Anda termasuk berzodiak <b>Scorpio</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Sagitarius</b>";
     break;
          }
        case '12' :
   if($tanggal_lahir<=21){
     echo "Anda termasuk berzodiak <b>Sagitarius</b>";
     break;
   }else{
     echo "Anda bezodiak <b>Capricon</b>";
     break;
          }
        default :
     echo "Bulan yang anda masukkan <b>salah</b>";
     break;
 }
      ?>

</body>
</head>
</html>

GAMBAR :




Read More ...