ETS PEMROGRAMAN WEB

Karina Soraya P
05111740000003
PWEB - C


MANAJEMEN PRESTASI SISWA

  • Source Code index.php
 <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Prestasi SMAN 1 Jember</title>   
   <link rel="icon" type="image/png" href="Logo_sman1jember.png">   
  </head>   
  <body>   
  <style type="text/css">   
  .header{    
   width: 100%;    
   margin: auto;    
   height: 120px;    
   line-height: 120px;    
   color: black;    
   font-family: "Comic Sans MS", cursive, sans-serif;    
   margin-top: 0;   
   background-color : grey;  
  }    
  .fieldset{   
   width : 700px;   
   height : 700px;   
  }   
  .topnav {   
   overflow: hidden;   
   background-color: grey;   
   width: 100%;   
  }   
  /* Style the links inside the navigation bar */   
  .topnav a {   
   float: left;   
   display: block;   
   color: black;   
   text-align: center;   
   padding: 14px 16px;   
   text-decoration: none;   
   font-size: 17px;   
  }   
  /* Change the color of links on hover */   
  .topnav a:hover {   
   background-color: grey;   
   color: black;   
  }   
  /* Style the "active" element to highlight the current page */   
  .topnav a.active {   
   background-color: #D32F2F;   
   color: white;   
  }   
  /* Style the search box inside the navigation bar */   
  .topnav input[type=text] {   
   float: right;   
   padding: 6px;   
   border: none;   
   margin-top: 8px;   
   margin-right: 16px;   
   font-size: 17px;   
  }   
  /* When the screen is less than 600px wide, stack the links and the search field vertically instead of horizontally */   
  @media screen and (max-width: 600px) {   
   .topnav a, .topnav input[type=text] {   
    float: none;   
    display: block;   
    text-align: left;   
    width: 100%;   
    margin: 0;   
    padding: 14px;   
   }   
   .topnav input[type=text] {   
    border: 1px solid #ccc;   
   }   
  }   
  .a {   
   position: relative;   
   text-align: center;   
   color: white;   
  }   
  </style>   
   <header>   
   </header>   
   <img src="Pres.jpg" align="center">   
 <div class="topnav" style="width: 100%;">   
  <a class="active" href="#home">Beranda</a>   
  <a href="Input.php">Input Prestasi</a>   
  <a href="List.php">List Prestasi</a>   
  <input type="text" placeholder="Search..">   
  </div>   
   <?php if(isset($_GET['status'])): ?>   
   <p>   
    <?php   
     if($_GET['status'] == 'sukses'){   
      echo "<center>Input Data Berhasil!</center>";   
     } else {   
      echo "<center>Input Data Gagal!</center>";   
     }   
    ?>   
   </p>   
   <?php endif; ?>   
   </body>   
  </html>   
  • Source Code Input.php
 <!DOCTYPE html>   
  <html>   
  <head>   
  <title>Prestasi SMAN 1 Jember</title>   
  <link rel="icon" type="image/png" href="Logo_sman1jember.png">   
  </head>   
  <style type="text/css">    
  fieldset{   
   width : 700px;   
   height : 300px;   
  }   
  form   
  {   
   margin:2em 0 0 0;   
  }   
  label   
  {   
   display:inline-block;   
   margin : 0 auto;   
   width:12em;   
   text-align :left;   
  }   
  input{    
  padding-left: 7px;    
  border: none;    
  border-bottom: 2px solid black;    
  height: 20px;    
  width: 250px;    
  font-size: 15px;    
  }    
  select{   
  padding-left: 10px;    
  border: none;    
  border-bottom: 2px solid black;    
  height: 20px;    
  width: 250px;    
  font-size: 15px;    
  }   
  .btn   
  {   
   display:inline-block;   
   padding:2px;   
   border:1px solid #ddd;   
   background:#eee;   
   color:#000;   
   text-decoration:none;   
  }   
  </style>    
  <body>   
   <div align="center" class="head_al">   
  <h2 class="head">Form Data Prestasi</h2>  
   <form method = 'post' action= "aksiForm.php">   
   <fieldset>   
    <p>   
     <label>Kelas &nbsp; :</label>   
     <select name="kelas">   
      <option value="mipa3">XII MIPA 1</option>   
      <option value="mipa2">XII MIPA 2</option>   
      <option value="ips">XII IIS</option>   
     </select>   
    </p>   
    <p>   
     <label>Semester &nbsp; :</label>   
     <select name="semes">   
      <option value="ganjil">Ganjil</option>   
      <option value="genap">Genap</option>   
     </select>   
    </p>   
    <br>  
   <a href="form-daftar.php">Tambah Prestasi Siswa</a>   
    </fieldset>  
    </form>   
  </body>   
  </html>  
  • Source Code List.php
 <!DOCTYPE html>   
  <html>   
  <head>   
  <title>Prestasi SMAN 1 Jember</title>   
  <link rel="icon" type="image/png" href="Logo_sman1jember.png">   
  </head>   
  <style type="text/css">    
  fieldset{   
   width : 700px;   
   height : 300px;   
  }   
  form   
  {   
   margin:2em 0 0 0;   
  }   
  label   
  {   
   display:inline-block;   
   margin : 0 auto;   
   width:12em;   
   text-align :left;   
  }   
  input{    
  padding-left: 7px;    
  border: none;    
  border-bottom: 2px solid black;    
  height: 20px;    
  width: 250px;    
  font-size: 15px;    
  }    
  select{   
  padding-left: 10px;    
  border: none;    
  border-bottom: 2px solid black;    
  height: 20px;    
  width: 250px;    
  font-size: 15px;    
  }   
  .btn   
  {   
   display:inline-block;   
   padding:2px;   
   border:1px solid #ddd;   
   background:#eee;   
   color:#000;   
   text-decoration:none;   
  }   
  </style>    
  <body>   
   <div align="center" class="head_al">   
  <h2 class="head">List Prestasi</h2>  
   <form method = 'post' action= "aksiForm.php">   
   <fieldset>   
    <p>   
     <label>Kelas &nbsp; :</label>   
     <select name="kelas">   
      <option value="mipa3">XII MIPA 1</option>   
      <option value="mipa2">XII MIPA 2</option>   
      <option value="ips">XII IIS</option>   
     </select>   
    </p>   
    <p>   
     <label>Semester &nbsp; :</label>   
     <select name="semes">   
      <option value="ganjil">Ganjil</option>   
      <option value="genap">Genap</option>   
     </select>   
    </p>   
    <br>  
   <a href="list-siswa.php">List Prestasi Siswa</a>   
    </fieldset>  
    </form>   
  </body>   
  </html>  
  • Source Code form-daftar.php
 <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Prestasi SMAN 1 Jember</title>   
   <link rel="icon" type="image/png" href="Logo_sman1jember.png">   
  </head>   
  <body>   
   <header>   
    <h3><center>Tambah Prestasi Siswa</center></h3>   
   </header>   
   <form action="proses-pendaftaran.php" method="POST">   
    <fieldset>   
   <p>   
     <label for="nama">Nama : </label>   
     <select name="nama">   
      <option>Maxime Bouttier</option>   
      <option>Toni Kroos</option>   
     <option>Gareth Bale</option>  
     </select>   
    </p>   
   <p>   
     <label for="jenis_prestasi">Jenis Prestasi: </label>   
     <select name="jenis_prestasi">   
      <option>Ekstrakulikuler</option>   
      <option>Akademik</option>   
     </select>   
    </p>   
    <p>   
     <label for="deskripsi">Deskripsi: </label>   
     <input type="text" name="deskripsi" placeholder="Deskripsi" />   
    </p>   
    <p>   
     <input type="submit" value="Daftar" name="daftar" />   
    </p>   
    </fieldset>   
   </form>   
   </body>   
  </html>   
  • Source Code 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'];   
   $jp = $_POST['jenis_prestasi'];   
   $deskripsi = $_POST['deskripsi'];   
   // buat query   
   $sql = "INSERT INTO prestasi (nama, jenis_prestasi, deskripsi) VALUE ('$nama', '$jp', '$deskripsi')";   
   $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...");   
  }   
  ?>   
  • Source Code list-siswa.php
 <?php include("config.php"); ?>   
  <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Prestasi SMAN 1 Jember</title>   
   <link rel="icon" type="image/png" href="Logo_sman1jember.png">    
  </head>   
  <body>   
   <center>   
   <header>   
    <h3>Prestasi Siswa</h3>   
   </header>   
   <nav>   
    <a href="form-daftar.php">[+] Tambah Baru</a>   
   </nav>   
   <br>   
   <table border="3">   
   <thead>   
    <tr>   
     <th>No</th>   
     <th>Nama</th>   
     <th>Jenis Prestasi</th>   
     <th>Deskripsi</th>   
    </tr>   
   </thead>   
   <tbody>   
    <?php   
    $sql = "SELECT * FROM prestasi";   
    $query = mysqli_query($db, $sql);   
    while($siswa = mysqli_fetch_array($query)){   
     echo "<tr>";   
     echo "<td>".$siswa['id']."</td>";   
     echo "<td>".$siswa['nama']."</td>";   
     echo "<td>".$siswa['jenis_prestasi']."</td>";   
     echo "<td>".$siswa['deskripsi']."</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>";   
     echo "</tr>";   
    }   
    ?>   
   </tbody>   
   </table>   
   <p>Total: <?php echo mysqli_num_rows($query) ?></p>   
   </center>   
   </body>   
  </html>   
  • Source Code hapus.php
 <?php   
  include("config.php");   
  if( isset($_GET['id']) ){   
   // ambil id dari query string   
   $id = $_GET['id'];   
   // buat query hapus   
   $sql = "DELETE FROM prestasi 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...");   
  }   
  ?>   
  • Source Code 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 prestasi 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>Prestasi SMAN 1 Jember</title>   
   <link rel="icon" type="image/png" href="Logo_sman1jember.png">   
  </head>   
  <body>   
   <header>   
    <h3>Formulir Edit Prestasi</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>   
     <?php $nama = $siswa['nama']; ?>   
     <select name="nama">   
      <option <?php echo ($nama == 'Maxime Bouttier') ? "selected": "" ?>>Maxime Bouttier</option>   
      <option <?php echo ($nama == 'Toni Kroos') ? "selected": "" ?>>Toni Kroos</option>   
      <option <?php echo ($nama == 'Gareth Bale') ? "selected": "" ?>>Gareth Bale</option>   
     </select>   
    </p>   
    <p>   
     <label for="jenis_prestasi">Jenis Prestasi: </label>   
     <?php $jp = $siswa['jenis_prestasi']; ?>   
     <select name="jenis_prestasi">   
      <option <?php echo ($jp == 'Ekstrakulikuler') ? "selected": "" ?>>Ekstrakulikuler</option>   
      <option <?php echo ($jp == 'Akademik') ? "selected": "" ?>>Akademik</option>   
     </select>   
    </p>   
    <p>   
     <label for="deskripsi">Deskripsi: </label>   
     <input type="text" name="deskripsi" placeholder="Deskripsi" value="<?php echo $siswa['deskripsi'] ?>" />   
    </p>   
    <p>   
     <input type="submit" value="Simpan" name="simpan" />   
    </p>   
    </fieldset>   
   </form>   
   </body>   
  </html>   
  • Source Code 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'];   
   $jp = $_POST['jenis_prestasi'];   
   $deskripsi = $_POST['deskripsi'];   
   // buat query update   
   $sql = "UPDATE prestasi SET nama='$nama', jenis_prestasi='$jp', deskripsi='$deskripsi' 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...");   
  }   
  ?>   
  • Source Code config.php
 <?php   
  $server = "erapor.karinasraya.xyz";   
  $user = "karinasr_karina";   
  $password = "24maret2014";   
  $nama_database = "karinasr_prestasi_siswa";   
  $db = mysqli_connect($server, $user, $password, $nama_database);   
  if( !$db ){   
   die("Gagal terhubung dengan database: " . mysqli_connect_error());   
  }   
  ?>  
  • Hasil
Tampilan beranda


Ketika klik "Input Prestasi". Pilih kelas dan semester yang ingin di inputkan.


Ketika klik "Tambah Prestasi Siswa". Inputkan datanya.


Jika data berhasil di input, akan muncul tulisan "Input Data Berhasil !" dan jika gagal, akan muncul tulisan "Input Data Gagal !"


Ketika klik "List Prestasi". Pilih kelas dan semester yang ingin dilihat.


Ketika klik "List Prestasi Siswa" akan ditampilkan data prestasi siswa.


Ketika klik "Hapus" data tersebut akan terhapus. Ketika klik "Edit" akan ditampilkan form editnya.


  • Bentuk Penyimpanan Datanya

Komentar

Postingan Populer