Selasa, 16 Oktober 2018

UTS-PWEB-C-DataPrestasi

DATA PRESTASI SISWA

Proses :
1. Membuat Database
2. Membuat proses PHP

Cara Kerja :
1. Pengguna membuka site awal dan memilih menu prestasi siswa.
2. Akan tampil tabel dengan atribut Nama Siswa, Prestasi Siswa, Keterangan.
3. Terdapat fitur :
       a. tambah baru untuk menambah siswa,
       b. edit untuk mengedit data siswa,
       c. hapus untuk menghapus data siswa,

Penampakan tabel database.


Tampilan Menu Prestasi Siswa

Pengisian Form Penambahan siswa

Halaman Awal, dan notifikasi keberhasilan penambahan siswa.

Tampilan Sudah bertambah

Menghapus siswa Andi.
Formulir Edit

Nama Nina Berhasil Diganti menjadi Nino



Source Codes :
config.php

 <?php  
 $server = "localhost";  
 $user = "root";  
 $password = "";  
 $nama_database = "e-rapor";  
 $db = mysqli_connect($server, $user, $password, $nama_database);  
 if( !$db ){  
   die("Gagal terhubung dengan database: " . mysqli_connect_error());  
 }  
 ?>  

form-edit.php

 <?php  
 include("config.php");  
 // kalau tidak ada id di query string  
 if( !isset($_GET['id_siswa']) ){  
   header('Location: list-siswa.php');  
 }  
 //ambil id dari query string  
 $id = $_GET['id_siswa'];  
 // buat query untuk ambil data dari database  
 $sql = "SELECT * FROM prestasi_siswa WHERE id_siswa=$id";  
 $query = mysqli_query($db, $sql);  
 $siswa = mysqli_fetch_assoc($query);  
 // jika data yang di-edit tidak ditemukan  
 if( mysqli_num_rows($query) < 1 ){  
   die("data tidak ditemukan...");  
 }  
 ?>  
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>UTS PWEB C</title>  
      <link rel="stylesheet" type="text/css" href="Style.css">  
 </head>  
 <body>  
      <div class="login">  
   <header>  
     <h3>Formulir Edit Siswa</h3>  
   </header>  
   <form action="proses-edit.php" method="POST">  
     <fieldset>  
       <input type="hidden" name="id" value="<?php echo $siswa['id_siswa'] ?>" />  
     <p>  
       <label for="nama">Nama: </label>  
       <input type="text" name="nama" placeholder="nama lengkap" value="<?php echo $siswa['nama_siswa'] ?>" />  
     </p>  
     <p>  
       <label for="prestasi">Prestasi: </label>  
       <textarea name="prestasi"><?php echo $siswa['prestasi'] ?></textarea>  
     </p>  
     <p>  
       <label for="keterangan">Keterangan: </label>  
       <textarea name="keterangan"><?php echo $siswa['keterangan'] ?></textarea>  
     </p>  
     <p>  
       <input type="submit" value="Simpan" name="simpan" />  
     </p>  
     </fieldset>  
   </form>  
      </div>  
   </body>  
 </html>  

hapus.php

 <?php  
 include("config.php");  
 if(isset($_GET['id_siswa']) ){  
   // ambil id dari query string  
   $id = $_GET['id_siswa'];  
   // buat query hapus  
   $sql = "DELETE FROM prestasi_siswa WHERE id_siswa=$id";  
   $query = mysqli_query($db, $sql);  
   // apakah query hapus berhasil?  
   if( $query ){  
     header('Location: list-siswa.php');  
   } else {  
     die("gagal menghapus...");  
   }  
 } else {  
   die("akses dilarang...");  
 }  
 ?>  

index.php

 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>UTS PWEB C</title>  
      <link rel="stylesheet" type="text/css" href="Style.css">  
 </head>  
 <body>   
 <div class="header">  
   <div class="container">  
    <h2>E-Rapor</h2>  
    <h1>SMK UTS JAYA</h1>     
   </div>  
  </div>  
  <div class="menu">  
   <ul>  
       <li>     <a href="#login">Login</a></li>  
    <li>      <a href="list-siswa.php">Prestasi Siswa</a></li>  
    <li>     <a href="#data">Data Siswa</a></li>  
    <li>     <a href="#data">Nilai Siswa</a></li>  
   </ul>   
  </div>  
 <?php if(isset($_GET['status'])): ?>  
   <p>  
     <?php  
       if($_GET['status'] == 'sukses'){  
         echo "Pendaftaran siswa baru berhasil!";  
       } else {  
         echo "Pendaftaran gagal!";  
       }  
     ?>  
   </p>  
 <?php endif; ?>  
      </body>  
 </html>  

list-siswa.php

 <?php include("config.php"); ?>  
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>UTS PWEB C</title>  
      <link rel="stylesheet" type="text/css" href="Style.css">  
 </head>  
 <body>  
     <div class="header">  
           <h1><center>LIST PRESTASI SISWA</center></h1>  
           </div>  
  <div class="menu">  
   <ul>  
       <li>     <a href="index.php">Home</a></li>  
    <li>      <a href="form-tambah.php">[+] Tambah Baru</a></li>  
   </ul>   
  </div>  
   <br>  
   <table id="siswa">  
   <thead>  
     <tr>  
       <th>No</th>  
       <th>Nama Siswa</th>  
       <th>Prestasi</th>  
       <th>Keterangan</th>  
       <th> </th>  
     </tr>  
   </thead>  
   <tbody>  
     <?php  
             $sql = "SELECT * FROM prestasi_siswa";  
                $query = mysqli_query($db, $sql);  
                $nomer = 0;  
                while($siswa = mysqli_fetch_array($query)){  
                echo "<tr>";  
                $nomer++;  
                echo "<td>".$nomer."</td>";  
                echo "<td>".$siswa['nama_siswa']."</td>";  
                echo "<td>".$siswa['prestasi']."</td>";  
                echo "<td>".$siswa['keterangan']."</td>";  
                echo "<td>";  
                echo "<a href='form-edit.php?id_siswa=".$siswa['id_siswa']."'>Edit</a> | ";  
                echo "<a href='hapus.php?id_siswa=".$siswa['id_siswa']."'>Hapus</a>";  
                echo "</td>";  
                }  
      ?>  
   </tbody>  
   </table>  
   <p>Total: <?php echo mysqli_num_rows($query) ?></p>  
   </body>  
 </html>  

form-tambah.php

 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>UTS PWEB C</title>  
      <link rel="stylesheet" type="text/css" href="Style.css">  
 </head>  
 <body>  
      <div class="login">  
   <header>  
     <h3>Formulir Penambahan Siswa</h3>  
   </header>  
   <form action="proses_tambah.php" method="POST">  
     <fieldset>  
     <p>  
       <label for="nama">Nama: </label>  
       <input type="text" name="nama" placeholder="nama lengkap" />  
     </p>  
     <p>  
       <label for="prestasi">Prestasi: </label>  
       <textarea name="prestasi"></textarea>  
     </p>  
     <p>  
       <label for="keterangan">Keterangan: </label>  
       <textarea name="keterangan"></textarea>  
     </p>  
     <p>  
       <input type="submit" value="Daftar" name="daftar" />  
     </p>  
     </fieldset>  
   </form>  
      </div>  
   </body>  
 </html>  

proses_tambah.php

 <?php  
 include("config.php");  
 // cek apakah tombol daftar sudah diklik atau blum?  
 if(isset($_POST['daftar'])){  
   // ambil data dari formulir  
   $nama = $_POST['nama'];  
   $prestasi = $_POST['prestasi'];  
   $ket = $_POST['keterangan'];  
   // buat query  
   $sql = "INSERT INTO prestasi_siswa (nama_siswa, prestasi, keterangan) VALUE ('$nama', '$prestasi', '$ket')";  
   $query = mysqli_query($db, $sql);  
   // apakah query simpan berhasil?  
   if( $query ) {  
     // kalau berhasil alihkan ke halaman index.php dengan status=sukses  
     header('Location: index.php?status=sukses');  
   } else {  
     // kalau gagal alihkan ke halaman indek.php dengan status=gagal  
     header('Location: index.php?status=gagal');  
   }  
 } else {  
   die("Akses dilarang...");  
 }  
 ?>  

proses-edit.php

 <?php  
 include("config.php");  
 // cek apakah tombol simpan sudah diklik atau blum?  
 if(isset($_POST['simpan'])){  
   // ambil data dari formulir  
   $id = $_POST['id'];  
   $nama = $_POST['nama'];  
   $prestasi = $_POST['prestasi'];  
   $ket = $_POST['keterangan'];  
   // buat query update  
   $sql = "UPDATE prestasi_siswa SET nama_siswa='$nama',prestasi='$prestasi', keterangan='$ket' WHERE id_siswa=$id";  
   $query = mysqli_query($db, $sql);  
   // apakah query update berhasil?  
   if( $query ) {  
     // kalau berhasil alihkan ke halaman list-siswa.php  
     header('Location: list-siswa.php');  
   } else {  
     // kalau gagal tampilkan pesan  
     die("Gagal menyimpan perubahan...");  
   }  
 } else {  
   die("Akses dilarang...");  
 }  
 ?>  

Style.css

 h2, h1 {  
  text-align: center;  
 }  
 h3 {  
   padding: 6px 6px 6px 32px;  
   text-decoration: none;  
   font-size: 25px;  
   display: block;  
 }  
 .login {  
  padding: 1em;  
  margin: 2em auto;  
  width: 17em;  
  background: #fff;  
  border-radius: 3px;  
 }  
 label {  
  font-size: 10pt;  
  color: #555;  
 }  
 input[type="text"],  
 input[type="email"],  
 textarea {  
  padding: 8px;  
  width: 95%;  
  background: #efefef;  
  border: 0;  
  font-size: 10pt;  
  margin: 6px 0px;  
 }  
 .tombol {  
  background: #3498db;  
  color: #fff;  
  border: 0;  
  padding: 5px 8px;  
 }  
 /*tes*/  
 body {  
  background:#00daff;  
  width:100%;  
  font-family:sans-serif;  
  margin:0 auto;  
 }  
 .header {  
  width:90%;  
  margin: 2em auto 0;  
  height:140px;  
  background: #00daff;  
  color:#fff;  
 }  
 .content {  
  border:2px solid #00daff;  
  width:90%;  
  margin:auto;  
  height:1200px;  
  padding:0.1px;  
  background:#fff;  
  color:#333;  
 }  
 #post {  
  width:70%;  
  float:left;  
  margin:auto;  
  background:#fff;  
  height:420px;  
 }  
 .undecor {  
  text-decoration:none;  
 }  
 .footer {  
  width:30%;  
  margin: 0 auto;  
  background:#00daff;  
  color:#fff;  
 }  
 .menu {  
  background-color: #00daff;   
  position:relative;  
  width:30%;  
  margin:0 auto;  
  padding:0 auto;  
 }   
 .container {  
  padding:1.5em;  
 }  
 .footer .container {  
  margin-left: 1.8em;  
  padding: 0.2em;  
 }  
 .menu ul {  
      list-style-type:none;  
      margin: 0;  
   padding: 0;  
   overflow: hidden;  
   background-color: #333;  
      font-family:Arial;  
      font-size:14px;  
 }  
 .block {  
   border: none;  
   background-color: #fff;  
   color: white;  
   padding: 14px 16px;  
   cursor: pointer;  
   text-align: center;  
 }  
 .block:hover {  
   background-color: red;  
   color: white;  
 }  
 .menu li {  
   float: left;  
 }  
 .menu li a, .dropbtn {  
   padding: 14px 16px;  
   display: inline-block;  
   color: white;  
   text-align: center;  
   text-decoration: none;  
 }  
 .menu li a:hover, .dropdown:hover .dropbtn {  
   background-color: red;  
 }  
 .menu li.dropdown {  
   display: inline-block;  
 }  
 .dropdown-content {  
   display: none;  
   position: absolute;  
   background-color: #f9f9f9;  
   min-width: 160px;  
   box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);  
   z-index: 1;  
 }  
 .dropdown-content a {  
   color: black;  
   padding: 12px 16px;  
   text-decoration: none;  
   display: block;  
   text-align: left;  
 }  
 .dropdown-content a:hover {background-color: #f1f1f1}  
 .dropdown:hover .dropdown-content {  
   display: block;  
 }  
 .header {  
  width:30%;  
  margin: 2em auto 0;  
  height:140px;  
  background: #00daff;  
  color:#fff;  
 }  
 #siswa {  
   font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;  
   border-collapse: collapse;  
   width: 80%;  
 }  
 #siswa td, #siswa th {  
   border: 1px solid #ddd;  
   padding: 8px;  
 }  
 #siswa tr:nth-child(odd){background-color: #fff;}  
 #siswa tr:nth-child(even){background-color: #f2f2f2;}  
 #siswa th {  
   padding-top: 12px;  
   padding-bottom: 12px;  
   text-align: left;  
   background-color: #4CAF50;  
   color: white;  
 }  

Minggu, 14 Oktober 2018

UTS-PBO-MANLESS-PARKINGMACHINE

Mesin Parkir Otomatis

Deskripsi : 
    Untuk Input jam masuk dan keluar akan dimasukkan otomatis dengan penekanan tombol pada mesin. Sehingga pada program ini akan dimasukkan secara manual karena alat input dianggap diatur oleh mesin. (dapat dipermudah dengan sistem array, tapi pada demonstrasi ini saya menggunakan metode langsung, karena input saat masuk dan input saat keluar disamakan).

Cara Kerja :
   Input diproses dan menghasilkan harga secara otomatis, input jam masuk dimasukkan pada nomor karcis diawal dan pada saat keluar, nomor karcis kembali diakses dan input waktu keluar diterima. Sehingga durasi didapatkan dan tiket pembayaran karcis keluar.
(Tiket tidak akan keluar sebelum pembayaran melalui penempelan kartu berlangsung)
Berikut penampilannya : 


  Berikut Source Codenya :

Machine :
 /**   
  * Sistem Parkir Elektronik   
  * @author CarWiMa  
  * 05111740000098   
  * PBO B    
  */   
  import java.util.Scanner;    
  import java.awt.event.*;    
  import javax.swing.*;    
  public class Machine   
  {    
   private static int cost,jenis ;   
   public static void main(String args[])    
   {    
     Scanner scan= new Scanner(System.in);   
     ParkirElektronik parkir = new ParkirElektronik();    
     System.out.println("Pilih jenis kendaraan anda : \n");   
     System.out.println("1. Motor ");   
     System.out.println("2. Mobil");   
     jenis=scan.nextInt();   
     switch(jenis){   
      case 1:   
      System.out.println("Masukkan Nomor Karcis kendaraan anda");    
      parkir.getKarcis();  
      parkir.getStart();   
      parkir.getEnd();   
      parkir.getDuration();  
      cost = parkir.getPrice(1000);  
      parkir.printKarcisOut();   
      break;    
      case 2:    
      System.out.println("Masukkan Nomor Karcis kendaraan anda");    
      parkir.getKarcis();  
      parkir.getStart();   
      parkir.getEnd();   
      parkir.getDuration();  
      cost = parkir.getPrice(3000);  
      parkir.printKarcisOut();   
      System.out.println("\n");   
      break;    
     }   
   }  
  }   

Parkir Elektronik:
  import java.awt.event.*;    
  import javax.swing.*;    
  import java.util.Scanner;   
  import java.util.ArrayList;    
  public class ParkirElektronik   
  {   
   private static int price;   
   private static int duration;    
   private static int start;   
   private static int end;   
   private static String NomorKarcis;   
   Scanner scan= new Scanner(System.in);   
   public ParkirElektronik(){   
    price = 0;   
   }    
   public int getPrice(int cost)   
   {   
    price = cost * duration;   
    return price;   
   }   
   public void getStart(){   
    System.out.println("Masukkan Jam Masuk : (sistem 24jam)");   
    start = scan.nextInt();  
   }   
   public void getKarcis(){   
      NomorKarcis = scan.nextLine();   
    }   
   public void getEnd(){   
    System.out.println("Masukkan Jam Keluar : (sistem 24jam)");   
    end = scan.nextInt();  
   }   
   public void getDuration(){   
    duration = end-start;  
   }   
  public void printKarcisOut(){   
    System.out.println("#########################");   
    System.out.println(" No Karcis : "+NomorKarcis);   
    System.out.println(" Karcis Parkir");   
    System.out.println(" Durasi : "+duration+ " Jam");   
    System.out.println(" "+price+" Rupiah");   
    System.out.println(" Sampai Jumpa");   
    System.out.println("#########################");   
   }   
  }   

Selasa, 09 Oktober 2018

PWEB-C:PENDAFTARAN SISWA

Sebuah form pendaftaran siswa

Tampilan Utama

Data yang sudah ada pada database.

Menambahkan siswa.

Pendaftaran berhasil.

List Terupdate

Mengedit nama.

Hasil.

Menghapus data.
config.php
 <?php  
 $server = "localhost";  
 $user = "root";  
 $password = "";  
 $nama_database = "pendaftaran_siswa";  
 $db = mysqli_connect($server, $user, $password, $nama_database);  
 if( !$db ){  
   die("Gagal terhubung dengan database: " . mysqli_connect_error());  
 }  
 ?>  

form-daftar.php
 <?php  
 $server = "localhost";  
 $user = "root";  
 $password = "";  
 $nama_database = "pendaftaran_siswa";  
 $db = mysqli_connect($server, $user, $password, $nama_database);  
 if( !$db ){  
   die("Gagal terhubung dengan database: " . mysqli_connect_error());  
 }  
 ?>  

form-edit.php
 <?php  
 include("config.php");  
 // kalau tidak ada id di query string  
 if( !isset($_GET['id']) ){  
   header('Location: list-siswa.php');  
 }  
 //ambil id dari query string  
 $id = $_GET['id'];  
 // buat query untuk ambil data dari database  
 $sql = "SELECT * FROM calon_siswa WHERE id=$id";  
 $query = mysqli_query($db, $sql);  
 $siswa = mysqli_fetch_assoc($query);  
 // jika data yang di-edit tidak ditemukan  
 if( mysqli_num_rows($query) < 1 ){  
   die("data tidak ditemukan...");  
 }  
 ?>  
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>Formulir Edit Siswa | SMK Coding</title>  
 </head>  
 <body>  
   <header>  
     <h3>Formulir Edit Siswa</h3>  
   </header>  
   <form action="proses-edit.php" method="POST">  
     <fieldset>  
       <input type="hidden" name="id" value="<?php echo $siswa['id'] ?>" />  
     <p>  
       <label for="nama">Nama: </label>  
       <input type="text" name="nama" placeholder="nama lengkap" value="<?php echo $siswa['nama'] ?>" />  
     </p>  
     <p>  
       <label for="alamat">Alamat: </label>  
       <textarea name="alamat"><?php echo $siswa['alamat'] ?></textarea>  
     </p>  
     <p>  
       <label for="jenis_kelamin">Jenis Kelamin: </label>  
       <?php $jk = $siswa['jenis_kelamin']; ?>  
       <label><input type="radio" name="jenis_kelamin" value="laki-laki" <?php echo ($jk == 'laki-laki') ? "checked": "" ?>> Laki-laki</label>  
       <label><input type="radio" name="jenis_kelamin" value="perempuan" <?php echo ($jk == 'perempuan') ? "checked": "" ?>> Perempuan</label>  
     </p>  
     <p>  
       <label for="agama">Agama: </label>  
       <?php $agama = $siswa['agama']; ?>  
       <select name="agama">  
         <option <?php echo ($agama == 'Islam') ? "selected": "" ?>>Islam</option>  
         <option <?php echo ($agama == 'Kristen') ? "selected": "" ?>>Kristen</option>  
         <option <?php echo ($agama == 'Hindu') ? "selected": "" ?>>Hindu</option>  
         <option <?php echo ($agama == 'Budha') ? "selected": "" ?>>Budha</option>  
         <option <?php echo ($agama == 'Atheis') ? "selected": "" ?>>Atheis</option>  
       </select>  
     </p>  
     <p>  
       <label for="sekolah_asal">Sekolah Asal: </label>  
       <input type="text" name="sekolah_asal" placeholder="nama sekolah" value="<?php echo $siswa['sekolah_asal'] ?>" />  
     </p>  
     <p>  
       <input type="submit" value="Simpan" name="simpan" />  
     </p>  
     </fieldset>  
   </form>  
   </body>  
 </html>  

hapus.php
 <?php  
 include("config.php");  
 if( isset($_GET['id']) ){  
   // ambil id dari query string  
   $id = $_GET['id'];  
   // buat query hapus  
   $sql = "DELETE FROM calon_siswa WHERE id=$id";  
   $query = mysqli_query($db, $sql);  
   // apakah query hapus berhasil?  
   if( $query ){  
     header('Location: list-siswa.php');  
   } else {  
     die("gagal menghapus...");  
   }  
 } else {  
   die("akses dilarang...");  
 }  
 ?>  

index.php
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>Pendaftaran Siswa Baru | SMK Coding</title>  
 </head>  
 <body>  
   <header>  
     <h3>Pendaftaran Siswa Baru</h3>  
     <h1>SMK Coding</h1>  
   </header>  
   <h4>Menu</h4>  
   <nav>  
     <ul>  
       <li><a href="form-daftar.php">Daftar Baru</a></li>  
       <li><a href="list-siswa.php">Pendaftar</a></li>  
     </ul>  
   </nav>  
 <?php if(isset($_GET['status'])): ?>  
   <p>  
     <?php  
       if($_GET['status'] == 'sukses'){  
         echo "Pendaftaran siswa baru berhasil!";  
       } else {  
         echo "Pendaftaran gagal!";  
       }  
     ?>  
   </p>  
 <?php endif; ?>  
   </body>  
 </html>  

list-siswa.php
 <?php include("config.php"); ?>  
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>Pendaftaran Siswa Baru | SMK Coding</title>  
 </head>  
 <body>  
   <header>  
     <h3>Siswa yang sudah mendaftar</h3>  
   </header>  
   <nav>  
     <a href="form-daftar.php">[+] Tambah Baru</a>  
   </nav>  
   <br>  
   <table border="1">  
   <thead>  
     <tr>  
       <th>No</th>  
       <th>Nama</th>  
       <th>Alamat</th>  
       <th>Jenis Kelamin</th>  
       <th>Agama</th>  
       <th>Sekolah Asal</th>  
       <th>Tindakan</th>  
     </tr>  
   </thead>  
   <tbody>  
     <?php  
             $sql = "SELECT * FROM calon_siswa";  
                $query = mysqli_query($db, $sql);  
                $nomer = 0;  
                while($siswa = mysqli_fetch_array($query)){  
                echo "<tr>";  
                $nomer++;  
                echo "<td>".$nomer."</td>";  
                echo "<td>".$siswa['nama']."</td>";  
                echo "<td>".$siswa['alamat']."</td>";  
                echo "<td>".$siswa['jenis_kelamin']."</td>";  
                echo "<td>".$siswa['agama']."</td>";  
                echo "<td>".$siswa['sekolah_asal']."</td>";  
                echo "<td>";  
                echo "<a href='form-edit.php?id=".$siswa['id']."'>Edit</a> | ";  
                echo "<a href='hapus.php?id=".$siswa['id']."'>Hapus</a>";  
                echo "</td>";  
                }  
      ?>  
   </tbody>  
   </table>  
   <p>Total: <?php echo mysqli_num_rows($query) ?></p>  
   </body>  
 </html>  

proses-pendaftaran.php
 <?php  
 include("config.php");  
 // cek apakah tombol daftar sudah diklik atau blum?  
 if(isset($_POST['daftar'])){  
   // ambil data dari formulir  
   $nama = $_POST['nama'];  
   $alamat = $_POST['alamat'];  
   $jk = $_POST['jenis_kelamin'];  
   $agama = $_POST['agama'];  
   $sekolah = $_POST['sekolah_asal'];  
   // buat query  
   $sql = "INSERT INTO calon_siswa (nama, alamat, jenis_kelamin, agama, sekolah_asal) VALUE ('$nama', '$alamat', '$jk', '$agama', '$sekolah')";  
   $query = mysqli_query($db, $sql);  
   // apakah query simpan berhasil?  
   if( $query ) {  
     // kalau berhasil alihkan ke halaman index.php dengan status=sukses  
     header('Location: index.php?status=sukses');  
   } else {  
     // kalau gagal alihkan ke halaman indek.php dengan status=gagal  
     header('Location: index.php?status=gagal');  
   }  
 } else {  
   die("Akses dilarang...");  
 }  
 ?>  

proses-edit.php
 <?php  
 include("config.php");  
 // cek apakah tombol simpan sudah diklik atau blum?  
 if(isset($_POST['simpan'])){  
   // ambil data dari formulir  
   $id = $_POST['id'];  
   $nama = $_POST['nama'];  
   $alamat = $_POST['alamat'];  
   $jk = $_POST['jenis_kelamin'];  
   $agama = $_POST['agama'];  
   $sekolah = $_POST['sekolah_asal'];  
   // buat query update  
   $sql = "UPDATE calon_siswa SET nama='$nama', alamat='$alamat', jenis_kelamin='$jk', agama='$agama', sekolah_asal='$sekolah' WHERE id=$id";  
   $query = mysqli_query($db, $sql);  
   // apakah query update berhasil?  
   if( $query ) {  
     // kalau berhasil alihkan ke halaman list-siswa.php  
     header('Location: list-siswa.php');  
   } else {  
     // kalau gagal tampilkan pesan  
     die("Gagal menyimpan perubahan...");  
   }  
 } else {  
   die("Akses dilarang...");  
 }  
 ?>  


PWEB-C PHP FORM

Membuat form dengan PHP.

Jadi pada jurnal kali ini saya ditugaskan untuk membuat sebuah form dengan menggunakan PHP. berikut tampilannya :


 Source Code:
 <!DOCTYPE html>   
  <html>   
  <head>   
    <title>Pembayaran Rekening Air</title>   
  </head>   
  <style type="text/css">   
    body{   
       margin-top: 30px;   
       font-family: arial;   
       background: #cfcfcf;   
    }   
    #ins{   
       height: 25px;   
       width: 300px;   
       font-weight: bold;   
       font-size: 14px;   
       border: solid #937 1px;   
    }   
    #in{   
       height: 25px;   
       width: 50px;   
       font-weight: bold;   
       font-size: 14px;   
       border: solid #937 1px;   
    }   
    #sel{   
       height: 25px;   
       width: 100px;   
       font-weight: bold;   
       font-size: 14px;   
       border: solid #937 1px;   
    }   
    #sub{   
       background: #0088cc;   
       height: 25px;   
       width: 100px;   
       font-weight: bold;   
       font-size: 14px;   
       border: solid #937 1px;   
       color: #fff;   
    }   
    #sb{   
       color: #fff;   
       background: #0088cc;   
       height: 25px;   
       width: 100px;   
       font-weight: bold;   
       font-size: 14px;   
       border: solid #937 1px;   
    }   
    table{   
       background: #66ccff;   
       border: solid #937 1px;   
       padding-left: 100px;   
       padding-right: 100px;   
       padding-bottom: 15px;   
       padding-top: 20px;   
    }   
  </style>   
  <body>   
  <form method="post" action="index.php">   
       <table align="center">   
             <tr>   
                     <th colspan="2"><font size="5">Pembayaran Rekening Air</font><hr color="#f0c1c1" width="700"></th>   
             </tr>   
             <tr>   
                     <th align="left">Nama</th>   
                     <td><input id="ins" type="text" name="nama"></td>   
             </tr>   
             <tr>   
                     <th align="left">Alamat</th>   
                     <td><input id="ins" type="text" name="alamat"></td>   
             </tr>   
             <tr>   
                     <th align="left">No.HP</th>   
                     <td><input id="ins" type="text" name="nohp"></td>   
             </tr>   
             <tr>   
                     <th align="left">Kode</th>   
                     <td><select id="sel" name="kode">   
                           <option>-Pilih-</option>   
                           <option value="A1">Pabrik</option>   
                           <option value="A2">Super</option>   
                           <option value="A3">Toko</option>   
                           <option value="A4">Biasa</option>   
                     </select></td>   
             </tr>   
             <?php   
             error_reporting(0);   
                     $kode = $_POST['kode'];   
                     $jp = $_POST['jp'];   
                     $by = $_POST['by'];   
                     $hp = $_POST['hp'];   
                           if ($kode == "A1") {   
                                $jp="Pelanggan Pabrik";   
                                $by="35000";   
                                $hp="1525";   
                           }   
                           else if ($kode == "A2") {   
                                $jp="Pelanggan Supermarket/Swalayan";   
                                $by="27900";   
                                $hp="1125";   
                           }   
                           else if ($kode == "A3") {   
                                $jp="Pelanggan Toko/Pasar";   
                                $by="21900";   
                                $hp="755";   
                           }   
                           else if ($kode == "A4") {   
                                $jp="Pelanggan Biasa/Normal";   
                                $by="17500";   
                                $hp="525";   
                           }   
             ?>   
             <tr>   
                     <th align="left">Pemakaian Air</th>   
                     <td><input id="in" type="text" name="pemakaian">&nbsp;<b><font size="4">Kubik</font></b></td>   
             </tr>   
             <tr>   
                     <th align="left">Jenis Pelanggan</th>   
                     <td><input id="ins" type="hidden" name="jp" value="<?php echo "$jp" ?>">   
                     <input id="ins" disabled="disabled" value="<?php echo "$jp" ?>"> ></td>   
             </tr>   
             <tr>   
                     <th align="left">Biaya Beban</th>   
                     <td><input id="ins" type="hidden" name="by" value="<?php echo "$by" ?>">   
                     <input id="ins" disabled="disabled" value="<?php echo "$by" ?>"> ></td>   
             </tr>   
             <tr>   
                     <th align="left">Harga Per Kubik</th>   
                     <td><input id="ins" type="hidden" name="hp" value="<?php echo "$hp" ?>">   
                     <input id="ins" disabled="disabled" value="<?php echo "$hp" ?>"> ></td>   
             </tr>   
             <?php   
                     $kode = $_POST['kode'];   
                     $jp = $_POST['jp'];   
                     $by = $_POST['by'];   
                     $hp = $_POST['hp'];   
                     $pemakaian = $_POST['pemakaian'];   
                     $tot = $_POST['tot'];   
                     $tot = $pemakaian*$hp+$by;   
             ?>   
             <tr>   
                     <th align="left">Total Pembayaran</th>   
                     <td><input id="ins" type="hidden" name="tot" value="<?php echo "$tot" ?>">   
                     <input id="ins" disabled="disabled" value="<?php echo "$tot" ?>"></td>   
             </tr>   
             <tr>   
                     <td colspan="2" height="50">   
                     <input id="sub" type="submit" name="submit" value="Proses">&nbsp;&nbsp;&nbsp;   
                     <input id="sb" type="reset" value="Hapus"></td>   
             </tr>   
             <tr>   
                     <td colspan="2" align="right"><font color="#f0c1c1">Copyright &copy; Me</font></td>   
             </tr>   
    </table>   
  </form>   
  </body>   
  </html>   

PBO-B MUSIC Organizer

Membuat Music Organizer dengan BlueJ

Pada jurnal kali ini, saya ingin menampilkan sebuah hasil latihan saya mengenai penggunaan array dengan merekayasa sebuah sistem music organizer dengan blue j

Relasi Antar Kelas :


Eksekusi tidak dapat ditampilkan karena hanya berupa musik, dan string file adalah lokasi pasti dari file yang diinginkan. Seperti pada contoh saya Membuat "‪D:\\SealOnline Blades of Destiny\\sound\\55.mp3" pada player dan setelah distart(), akan mulai.







Class MusicOrganizer
 /**  
  * MusicOrganizer Class.  
  *  
  * @author Carwima  
  * @version 1.0Beta  
  */  
 import java.util.ArrayList;  
 public class MusicOrganizer  
 {  
   private ArrayList<String> music; //Music list  
   private MusicPlayer player; //Player  
   /**  
    * Constructor.  
    */  
   public MusicOrganizer()  
   {  
     music = new ArrayList<String>();  
     player = new MusicPlayer();  
   }  
   /**  
    * Method to add music to list. Input mp3 file path here  
    */  
   public void addMusic(String file)  
   {  
     music.add(file);  
   }  
   /**  
    * Show total number of music.  
    */  
   public int getSize()  
   {  
     return music.size();  
   }  
   /**  
    * Show what music at certain index.  
    */  
   public void show(int index)  
   {  
     if (index >= 0 && index < music.size())  
     {  
       System.out.println(music.get(index));  
     }  
   }  
   /**  
    * Method to remove music from list.  
    */  
   public void removeMusic(int index)  
   {  
     if (index >= 0 && index < music.size())  
     {  
       music.remove(index);  
     }  
   }  
   /**  
    * Method to play selected music.  
    */  
   public void start(int index)  
   {  
     player.startPlaying(music.get(index));  
   }  
   /**  
    * Stop playing music.  
    */  
   public void stop()  
   {  
     player.stop();  
   }  
 }  

Class MusicPlayer
 import java.io.BufferedInputStream;  
 import java.io.FileInputStream;  
 import java.io.InputStream;  
 import java.io.IOException;  
 import javazoom.jl.decoder.JavaLayerException;  
 import javazoom.jl.player.AudioDevice;  
 import javazoom.jl.player.FactoryRegistry;  
 import javazoom.jl.player.advanced.AdvancedPlayer;  
 /**  
  * Provide basic playing of MP3 files via the javazoom library.  
  * See http://www.javazoom.net/  
  *   
  * @author David J. Barnes and Michael Kölling  
  * @version 2016.02.29  
  */  
 public class MusicPlayer  
 {  
   // The current player. It might be null.  
   private AdvancedPlayer player;  
   /**  
    * Constructor for objects of class MusicFilePlayer  
    */  
   public MusicPlayer()  
   {  
     player = null;  
   }  
   /**  
    * Play a part of the given file.  
    * The method returns once it has finished playing.  
    * @param filename The file to be played.  
    */  
   public void playSample(String filename)  
   {  
     try {  
       setupPlayer(filename);  
       player.play(500);  
     }  
     catch(JavaLayerException e) {  
       reportProblem(filename);  
     }  
     finally {  
       killPlayer();  
     }  
   }    
   /**  
    * Start playing the given audio file.  
    * The method returns once the playing has been started.  
    * @param filename The file to be played.  
    */  
   public void startPlaying(final String filename)  
   {  
     try {  
       setupPlayer(filename);  
       Thread playerThread = new Thread() {  
           public void run()  
           {  
             try {  
               player.play(5000);  
             }  
             catch(JavaLayerException e) {  
               reportProblem(filename);  
             }  
             finally {  
               killPlayer();  
             }  
           }  
         };  
       playerThread.start();  
     }  
     catch (Exception ex) {  
       reportProblem(filename);  
     }  
   }  
   public void stop()  
   {  
     killPlayer();  
   }  
   /**  
    * Set up the player ready to play the given file.  
    * @param filename The name of the file to play.  
    */  
   private void setupPlayer(String filename)  
   {  
     try {  
       InputStream is = getInputStream(filename);  
       player = new AdvancedPlayer(is, createAudioDevice());  
     }  
     catch (IOException e) {  
       reportProblem(filename);  
       killPlayer();  
     }  
     catch(JavaLayerException e) {  
       reportProblem(filename);  
       killPlayer();  
     }  
   }  
   /**  
    * Return an InputStream for the given file.  
    * @param filename The file to be opened.  
    * @throws IOException If the file cannot be opened.  
    * @return An input stream for the file.  
    */  
   private InputStream getInputStream(String filename)  
   throws IOException  
   {  
     return new BufferedInputStream(  
       new FileInputStream(filename));  
   }  
   /**  
    * Create an audio device.  
    * @throws JavaLayerException if the device cannot be created.  
    * @return An audio device.  
    */  
   private AudioDevice createAudioDevice()  
   throws JavaLayerException  
   {  
     return FactoryRegistry.systemRegistry().createAudioDevice();  
   }  
   /**  
    * Terminate the player, if there is one.  
    */  
   private void killPlayer()  
   {  
     synchronized(this) {  
       if(player != null) {  
         player.stop();  
         player = null;  
       }  
     }  
   }  
   /**  
    * Report a problem playing the given file.  
    * @param filename The file being played.  
    */  
   private void reportProblem(String filename)  
   {  
     System.out.println("There was a problem playing: " + filename);  
   }  
 }  

PBO-B AUCTION

Membuat lelang dengan pemrograman berorientasi objek

Pada jurnal kali ini, saya ingin menampilkan sebuah hasil latihan saya mengenai penggunaan array dengan merekayasa sebuah sistem pelelangan dengan blue j

Relasi Antar Kelas :

Cuplikan lelang :

Jadi, ketika dibuat objek sebuah tempat lelang dan dimasukkan barang pada enterLot(), barang akan teridentifikasi. Selanjutnya dilakukan bid, dengan menyertakan nama orang yang sudah diisi pada class person. Kemudian close() dijalankan untuk menutup lelang.

Class AuctionPlace (Tempat lelang)
  import java.util.ArrayList;   
 /**  
  * Auction  
  *   
  * @author Carwima  
  * @version 1.0Beta   
  */   
 public class AuctionPlace  
 {   
   private ArrayList<Lot> lots;   
   private int nextLotNumber;   
   public AuctionPlace()   
   {   
    lots = new ArrayList<Lot>();   
    nextLotNumber = 1;   
   }   
   public void enterLot(String description)   
   {   
    lots.add(new Lot(nextLotNumber, description));   
    nextLotNumber++;   
   }   
   public void showLots()   
   {   
    for(Lot lot : lots)   
    {   
     System.out.println(lot.toString());   
    }   
   }   
   public void makeABid(int lotNumber, Person bidder, long value)   
   {   
    Lot selectedLot = getLot(lotNumber);   
    if (selectedLot != null)   
    {   
     boolean succesful = selectedLot.bidFor(new Bid(bidder, value));   
     if (succesful)   
     {   
      System.out.println("The bid for lot number " + lotNumber + " was succesful.");   
     }   
     else   
     {   
      //Report which bid is higher   
      Bid highestBid = selectedLot.getHighestBid();   
      System.out.println("Lot number: " + lotNumber + " already has a bid of: " + highestBid.getValue());   
     }   
    }   
   }   
   public Lot getLot(int lotNumber)   
   {   
    if((lotNumber >= 1) && (lotNumber < nextLotNumber))   
    {   
     //The number seems to be reasonable   
     Lot selectedLot = lots.get(lotNumber-1);   
     //Include a confidence check to be sure we have the right lot   
     if (selectedLot.getNumber() != lotNumber)   
     {   
      System.out.println("Internal error: Lot number " + selectedLot.getNumber() + " was returned instead of " + lotNumber);   
      selectedLot = null;   
     }   
     return selectedLot;   
    }   
    else   
    {   
     System.out.println("Lot number: " + lotNumber + " does not exist.");   
     return null;   
    }   
   }   
   public void close()   
   {   
    System.out.println("Closing auction.");   
    for (Lot lot : lots)   
    {   
     System.out.println(lot.getNumber() + ": " + lot.getDescription());   
     if (lot.getHighestBid() == null)   
     {   
      System.out.println (" (No bids) ");   
     }   
     else   
     {   
      Bid highestBid = lot.getHighestBid();   
      System.out.println(" sold to " + highestBid.getBidder().getName() + " for " + highestBid.getValue());   
     }   
    }   
   }   
  }   

Class Lot (barang yang di lelang)
 /**  
  * Maintain Lots  
  *   
  * @author Carwima  
  * @version 1.0Beta   
  */   
 public class Lot   
  {    
   private final int number;   
   private String description;   
   private Bid highestBid;   
   public Lot (int number, String description)   
   {   
    this.number = number;   
    this.description = description;   
    this.highestBid = null;   
   }   
   public boolean bidFor(Bid bid)   
   {   
    if (highestBid==null)   
    {   
     highestBid=bid;   
     return true;   
    }   
    else if (bid.getValue() > highestBid.getValue())   
    {   
     highestBid = bid;   
     return true;   
    }   
    else   
    {   
     return false;   
    }   
   }   
   public String toString()   
   {   
    String details = number + ": " + description;   
    if (highestBid != null)   
    {   
     details += " Bid: " + highestBid.getValue();   
    }   
    else   
    {   
     details += " (No bid))";   
    }   
    return details;   
   }   
   public int getNumber()   
   {   
    return number;   
   }   
   public String getDescription()   
   {   
    return description;   
   }   
   public Bid getHighestBid()   
   {   
    return highestBid;   
   }   
  }   

Class Bid (harga lelang)
  /**   
  * A class that models an auction bid   
  *   
  * @author Carwima  
  * @version 1.0Beta   
  */   
  public class Bid   
  {   
   private final Person bidder;   
   private final long value;   
   public Bid(Person bidder, long value)   
   {   
    this.bidder = bidder;   
    this.value = value;   
   }   
   public Person getBidder()   
   {   
    return bidder;   
   }   
   public long getValue()   
   {   
    return value;   
   }   
  }   

Class Person (partisipan)
  /**   
  * Participant  
  *   
  * @author Carwima  
  * @version 1.0Beta   
  */   
  public class Person   
  {   
   private final String name;   
   public Person (String name)   
   {   
    this.name = name;   
   }   
   public String getName()   
   {   
    return name;   
   }   
  }   

Selasa, 02 Oktober 2018

TUGAS PWEB C

Membuat form validasi.

Pada jurnal kali ini, saya ingin menyampaikan sedikit mengenai form yang terdapat pada web saya.
Hyperlink tidak bekerja? manual ke berita.enlightarts.com.

Cara kerjanya adalah dengan menggunakan script, email akan diperiksa apakah valid/tidak, dan otomatis akan mengecek data username yang pernah diinput pada browser. Hal ini bertujuan untuk memudahkan input yang berulang.

Tampilan :


HTML FORM:
      <div class="login">  
           <form action="#" method="POST" onSubmit="validasi()">  
                <div>  
                     <label>Nama Lengkap:</label>  
                     <input type="text" name="nama" id="nama" />  
                </div>  
                <div>  
                     <label>Tanggal Lahir:</label>  
                     <input type="text" name="nama" id="nama" />  
                </div>  
                <div>  
                     <label>Nomor HP:</label>  
                     <input type="text" name="nama" id="nama" />  
                </div>  
                <div>  
                     <label>Email:</label>  
                     <input type="email" name="email" id="email" />  
                </div>  
                <div>  
                     <label>Alamat:</label>  
                     <textarea cols="40" rows="5" name="alamat" id="alamat"></textarea>  
                </div>  
                <div>  
                     <label>Topik Yang Disukai:</label>  
                     <input type="text" name="nama" id="nama" />  
                </div>  
                <div>  
                     <input type="submit" value="Daftar" class="tombol">  
                </div>  
           </form>  
      </div>  

SCRIPT FORM :
 <script type="text/javascript">  
      function validasi() {  
           var nama = document.getElementById("nama").value;  
           var email = document.getElementById("email").value;  
           var alamat = document.getElementById("alamat").value;  
           if (nama != "" && email!="" && alamat !="") {  
                return true;  
           }else{  
                alert('Anda harus mengisi data dengan lengkap !');  
           }  
      }  
 </script>  

CSS FORM :
 .login {  
  padding: 1em;  
  margin: 2em auto;  
  width: 17em;  
  background: #fff;  
  border-radius: 3px;  
 }  
 label {  
  font-size: 10pt;  
  color: #555;  
 }  
 input[type="text"],  
 input[type="email"],  
 textarea {  
  padding: 8px;  
  width: 95%;  
  background: #efefef;  
  border: 0;  
  font-size: 10pt;  
  margin: 6px 0px;  
 }  
 .tombol {  
  background: #3498db;  
  color: #fff;  
  border: 0;  
  padding: 5px 8px;  
 }