EAS PWEB C

Nama : Ifta Jihan N
NRP : 05111740000034
Kelas : PWEB C

Untuk rancangan database saya, saya memakai 2 tabel yaitu tabel siswa untuk menyimpa data siswa

dan users untuk menyimpan nisn sebagai username dan password untuk log in ke laman web.


Rancangan interface yang saya buat:
Untuk halaman log in

halaman setelah log in, untuk memilih menu isi data, lihat dan download data, dan Edit/Hapus data


halaman untuk isi data atau mengedit data


Untuk web saya dapat dibuka di http://ppdb-jihan.cokopi.store atau bisa klik Link
Berikut ini source code nya:
1. config.php

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

2. download.php

  <?php    
  //export.php    
  $connect = mysqli_connect("localhost", "cokopist_jihan", "cokopist_jihan", "cokopist_jihan");   
  $output = '';   
  if(isset($_POST["download"]))   
  {   
  $query = "SELECT * FROM siswa";   
  $result = mysqli_query($connect, $query);   
  if(mysqli_num_rows($result) > 0)   
  {   
  $output .= '   
   <table class="table" bordered="1">    
       <tr>    
        <th>NISN</th>    
        <th>NIK</th>    
        <th>Nama Lengkap</th>   
        <th>Agama</th>    
        <th>Tempat Lahir</th>   
        <th>Tanggal Lahir</th>   
        <th>Jenis Kelamin</th>   
        <th>Alamat</th>   
        <th>Provinsi</th>   
        <th>Kota</th>   
        <th>Telepon</th>  
        <th>Sekolah Asal</th>   
        <th>Sekolah Pilihan</th>   
       </tr>   
  ';   
  while($row = mysqli_fetch_array($result))   
  {   
   $output .= '   
   <tr>    
        <td>'.$row["nisn"].'</td>    
        <td>'.$row["nik"].'</td>    
        <td>'.$row["nama_lengkap"].'</td>    
        <td>'.$row["agama"].'</td>   
        <td>'.$row["tempat_lahir"].'</td>   
        <td>'.$row["tgl_lahir"].'</td>   
        <td>'.$row["jenis_kel"].'</td>    
        <td>'.$row["alamat"].'</td>    
        <td>'.$row["provinsi"].'</td>    
        <td>'.$row["kota"].'</td>   
        <td>'.$row["telepon"].'</td>   
        <td>'.$row["sekolah_asal"].'</td>   
        <td>'.$row["sekolah_pilihan"].'</td>   
       </tr>   
   ';   
  }   
  $output .= '</table>';   
  header('Content-Type: application/xls');   
  header('Content-Disposition: attachment; filename=download.xls');   
  echo $output;   
  }   
  }   
  ?>   

3. errors.php
  <?php if (count($errors) > 0) : ?>   
  <div class="error">   
     <?php foreach ($errors as $error) : ?>   
     <p><?php echo $error ?></p>   
     <?php endforeach ?>   
  </div>   
  <?php endif ?>   

4. login.css
 /* BASIC */  
 html {  
  background-color: #56baed;  
 }  
 body {  
  font-family: "Poppins", sans-serif;  
  height: 100vh;  
 }  
 a {  
  color: #92badd;  
  display:inline-block;  
  text-decoration: none;  
  font-weight: 400;  
 }  
 h2 {  
  text-align: center;  
  font-size: 16px;  
  font-weight: 600;  
  text-transform: uppercase;  
  display:inline-block;  
  margin: 40px 8px 10px 8px;   
  color: #cccccc;  
 }  
 /* STRUCTURE */  
 .wrapper {  
  display: flex;  
  align-items: center;  
  flex-direction: column;   
  justify-content: center;  
  width: 100%;  
  min-height: 100%;  
  padding: 20px;  
 }  
 #formContent {  
  -webkit-border-radius: 10px 10px 10px 10px;  
  border-radius: 10px 10px 10px 10px;  
  background: #fff;  
  padding: 30px;  
  width: 90%;  
  max-width: 450px;  
  position: relative;  
  padding: 0px;  
  -webkit-box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);  
  box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);  
  text-align: center;  
 }  
 #formFooter {  
  background-color: #f6f6f6;  
  border-top: 1px solid #dce8f1;  
  padding: 25px;  
  text-align: center;  
  -webkit-border-radius: 0 0 10px 10px;  
  border-radius: 0 0 10px 10px;  
 }  
 /* TABS */  
 h2.inactive {  
  color: #cccccc;  
 }  
 h2.active {  
  color: #0d0d0d;  
  border-bottom: 2px solid #5fbae9;  
 }  
 /* FORM TYPOGRAPHY*/  
 input[type=button], input[type=submit], input[type=reset] {  
  background-color: #56baed;  
  border: none;  
  color: white;  
  padding: 15px 80px;  
  text-align: center;  
  text-decoration: none;  
  display: inline-block;  
  text-transform: uppercase;  
  font-size: 13px;  
  -webkit-box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);  
  box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4);  
  -webkit-border-radius: 5px 5px 5px 5px;  
  border-radius: 5px 5px 5px 5px;  
  margin: 5px 20px 40px 20px;  
  -webkit-transition: all 0.3s ease-in-out;  
  -moz-transition: all 0.3s ease-in-out;  
  -ms-transition: all 0.3s ease-in-out;  
  -o-transition: all 0.3s ease-in-out;  
  transition: all 0.3s ease-in-out;  
 }  
 input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {  
  background-color: #39ace7;  
 }  
 input[type=button]:active, input[type=submit]:active, input[type=reset]:active {  
  -moz-transform: scale(0.95);  
  -webkit-transform: scale(0.95);  
  -o-transform: scale(0.95);  
  -ms-transform: scale(0.95);  
  transform: scale(0.95);  
 }  
 input[type=text], input[type=password] {  
  background-color: #f6f6f6;  
  border: none;  
  color: #0d0d0d;  
  padding: 15px 32px;  
  text-align: center;  
  text-decoration: none;  
  display: inline-block;  
  font-size: 16px;  
  margin: 5px;  
  width: 85%;  
  border: 2px solid #f6f6f6;  
  -webkit-transition: all 0.5s ease-in-out;  
  -moz-transition: all 0.5s ease-in-out;  
  -ms-transition: all 0.5s ease-in-out;  
  -o-transition: all 0.5s ease-in-out;  
  transition: all 0.5s ease-in-out;  
  -webkit-border-radius: 5px 5px 5px 5px;  
  border-radius: 5px 5px 5px 5px;  
 }  
 input[type=text]:focus {  
  background-color: #fff;  
  border-bottom: 2px solid #5fbae9;  
 }  
 input[type=text]:placeholder {  
  color: #cccccc;  
 }  
 /* ANIMATIONS */  
 /* Simple CSS3 Fade-in-down Animation */  
 .fadeInDown {  
  -webkit-animation-name: fadeInDown;  
  animation-name: fadeInDown;  
  -webkit-animation-duration: 1s;  
  animation-duration: 1s;  
  -webkit-animation-fill-mode: both;  
  animation-fill-mode: both;  
 }  
 @-webkit-keyframes fadeInDown {  
  0% {  
   opacity: 0;  
   -webkit-transform: translate3d(0, -100%, 0);  
   transform: translate3d(0, -100%, 0);  
  }  
  100% {  
   opacity: 1;  
   -webkit-transform: none;  
   transform: none;  
  }  
 }  
 @keyframes fadeInDown {  
  0% {  
   opacity: 0;  
   -webkit-transform: translate3d(0, -100%, 0);  
   transform: translate3d(0, -100%, 0);  
  }  
  100% {  
   opacity: 1;  
   -webkit-transform: none;  
   transform: none;  
  }  
 }  
 /* Simple CSS3 Fade-in Animation */  
 @-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }  
 @-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }  
 @keyframes fadeIn { from { opacity:0; } to { opacity:1; } }  
 .fadeIn {  
  opacity:0;  
  -webkit-animation:fadeIn ease-in 1;  
  -moz-animation:fadeIn ease-in 1;  
  animation:fadeIn ease-in 1;  
  -webkit-animation-fill-mode:forwards;  
  -moz-animation-fill-mode:forwards;  
  animation-fill-mode:forwards;  
  -webkit-animation-duration:1s;  
  -moz-animation-duration:1s;  
  animation-duration:1s;  
 }  
 .fadeIn.first {  
  -webkit-animation-delay: 0.4s;  
  -moz-animation-delay: 0.4s;  
  animation-delay: 0.4s;  
 }  
 .fadeIn.second {  
  -webkit-animation-delay: 0.6s;  
  -moz-animation-delay: 0.6s;  
  animation-delay: 0.6s;  
 }  
 .fadeIn.third {  
  -webkit-animation-delay: 0.8s;  
  -moz-animation-delay: 0.8s;  
  animation-delay: 0.8s;  
 }  
 .fadeIn.fourth {  
  -webkit-animation-delay: 1.2s;  
  -moz-animation-delay: 1.2s;  
  animation-delay: 1.2s;  
 }  
 .fadeIn.fifth {  
  -webkit-animation-delay: 1s;  
  -moz-animation-delay: 1s;  
  animation-delay: 1s;  
 }  
 /* Simple CSS3 Fade-in Animation */  
 .underlineHover:after {  
  display: block;  
  left: 0;  
  bottom: -10px;  
  width: 0;  
  height: 2px;  
  background-color: #56baed;  
  content: "";  
  transition: width 0.2s;  
 }  
 .underlineHover:hover {  
  color: #0d0d0d;  
 }  
 .underlineHover:hover:after{  
  width: 100%;  
 }  
 h1{  
   color:#60a0ff;  
 }  
 /* OTHERS */  
 *:focus {  
   outline: none;  
 }   
 #icon {  
  width:30%;  
 }  

5. login.php
  <?php include('server.php') ?>   
  <!DOCTYPE html>   
  <html>   
  <head>   
  <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
  <title>PPDB Online</title>   
  <link rel="stylesheet" type="text/css" href="login.css">   
   <link href="css/bootstrap.min.css" rel="stylesheet">   
  </head>   
  <body>   
   <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="login.php">Login</a>  
       </li>  
       <li class="nav-item">  
        <a class="nav-link" href="register.php">Register</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>  
   <div class="wrapper fadeInDown">  
  <div id="formContent">  
   <!-- Tabs Titles -->  
   <!-- Icon -->  
   <div class="fadeIn first">  
    <h1>Log In</h1>  
   </div>  
   <!-- Login Form -->  
   <form method="post" action="login.php">  
    <input type="text" id="nisn" class="fadeIn second" name="nisn" placeholder="NISN" value="<?php echo $nisn; ?>">  
    <input type="password" id="password" class="fadeIn third" name="password" placeholder="Password">  
    <input type="submit" class="fadeIn fourth" value="Log In" name="login_user">  
   </form>  
   <!-- Remind Passowrd -->  
   <div id="formFooter">  
    <a class="underlineHover" href="register.php">Don't have an account? Sign Up here.</a>  
   </div>  
  </div>  
 </div>  
  </body>   
  </html>   

6. register.php
  <?php include('server.php') ?>   
  <!DOCTYPE html>   
  <html>   
  <head>   
  <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
  <title>PPDB Online</title>   
  <link rel="stylesheet" type="text/css" href="login.css">   
   <link href="css/bootstrap.min.css" rel="stylesheet">  
  </head>   
  <body>   
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="login.php">Login</a>  
       </li>  
       <li class="nav-item">  
        <a class="nav-link" href="register.php">Register</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>  
 <div class="wrapper fadeInDown">  
  <div id="formContent">  
   <!-- Tabs Titles -->  
   <!-- Icon -->  
   <div class="fadeIn first">  
    <h1>Register</h1>  
   </div>  
   <!-- Login Form -->  
   <form method="post" action="register.php">  
    <input type="text" id="nisn" class="fadeIn second" name="nisn" placeholder="NISN" value="<?php echo $nisn; ?>">  
    <input type="password" id="ipassword" class="fadeIn third" name="ipassword" placeholder="Password">  
    <input type="password" id="cpassword" class="fadeIn fifth" name="cpassword" placeholder="Confirm Password">  
    <input type="submit" class="fadeIn fourth" value="Register" name="reg_user">  
   </form>  
   <!-- Remind Passowrd -->  
   <div id="formFooter">  
    <a class="underlineHover" href="login.php">Already have an account? Login here.</a>  
   </div>  
  </div>  
 </div>  
  </body>   
  </html>   

7. server.php
 <?php   
  session_start();   
  // initializing variables   
  $nisn = "";   
  $errors = array();    
  // connect to the database   
  $db = mysqli_connect('localhost', 'cokopist_jihan', 'cokopist_jihan', 'cokopist_jihan');   
  // REGISTER USER   
  if (isset($_POST['reg_user'])) {   
  // receive all input values from the form   
  $nisn = mysqli_real_escape_string($db, $_POST['nisn']);   
  // $email = mysqli_real_escape_string($db, $_POST['email']);   
  $ipassword = mysqli_real_escape_string($db, $_POST['ipassword']);   
  $cpassword = mysqli_real_escape_string($db, $_POST['cpassword']);   
  // form validation: ensure that the form is correctly filled ...   
  // by adding (array_push()) corresponding error unto $errors array   
  if (empty($nisn)) { array_push($errors, "NISN is required"); }   
  // if (empty($email)) { array_push($errors, "Email is required"); }   
  if (empty($ipassword)) { array_push($errors, "Password is required"); }   
  if ($ipassword != $cpassword) {   
    array_push($errors, "The two passwords do not match");   
  }   
  // first check the database to make sure    
  // a user does not already exist with the same nisn and/or email   
  $user_check_query = "SELECT * FROM users WHERE nisn='$nisn' LIMIT 1";   
  $result = mysqli_query($db, $user_check_query);   
  $user = mysqli_fetch_assoc($result);   
  if ($user) { // if user exists   
   if ($user['nisn'] === $nisn) {   
   array_push($errors, "nisn already exists");   
   }   
   // if ($user['email'] === $email) {   
   // array_push($errors, "email already exists");   
   // }   
  }   
  // Finally, register user if there are no errors in the form   
  if (count($errors) == 0) {   
     $password = md5($ipassword);//encrypt the password before saving in the database   
     $query = "INSERT INTO users (nisn, password)    
          VALUES('$nisn', '$password')";   
     mysqli_query($db, $query);   
     $_SESSION['nisn'] = $nisn;   
     $_SESSION['success'] = "You are now logged in";   
     header('location: login.php');   
  }   
  }   
  // ...    
  if (isset($_POST['login_user'])) {   
  $nisn = mysqli_real_escape_string($db, $_POST['nisn']);   
  $password = mysqli_real_escape_string($db, $_POST['password']);   
  if (empty($nisn)) {   
     array_push($errors, "nisn is required");   
  }   
  if (empty($password)) {   
     array_push($errors, "Password is required");   
  }   
  if (count($errors) == 0) {   
     $password = md5($password);   
     $query = "SELECT * FROM users WHERE nisn='$nisn' AND password='$password'";   
     $results = mysqli_query($db, $query);   
     if (mysqli_num_rows($results) == 1) {   
     $_SESSION['nisn'] = $nisn;   
     $_SESSION['success'] = "You are now logged in";   
     header('location: index.php');   
     }else {   
       array_push($errors, "Wrong nisn/password combination");   
     }   
  }   
  }   
  ?>   

8. form-daftar.php
  <!DOCTYPE html>   
  <html>   
  <html lang="en">  
  <head>   
   <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
    <title>Pendaftaran Siswa Online</title>   
     <link href="css/bootstrap.min.css" rel="stylesheet">  
    <link rel="stylesheet" type="text/css" href="form.css">   
  </head>   
  <body>  
   <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="index.php?logout='1'">Logout</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>  
   <div class="container contact-form">  
       <div class="contact-image">  
         <img src="PPDB.png">  
       </div>  
       <form method="post" action="proses-pendaftaran.php">  
         <h3>Formulir Pendaftaran</h3>  
         <div class="row">  
           <div class="col-md-6">  
             <div class="form-group">  
               <input type="text" name="nisn" class="form-control" placeholder="NISN" />  
             </div>  
             <div class="form-group">  
               <input type="text" name="nik" class="form-control" placeholder="NIK" />  
             </div>  
             <div class="form-group">  
               <input type="text" name="nama_lengkap" class="form-control" placeholder="Nama Lengkap"/>  
             </div>  
             <div class="form-group">  
               <select name="agama" class="form-control">   
               <option>Islam</option>   
               <option>Kristen</option>   
               <option>Hindu</option>   
               <option>Budha</option>   
               <option>Atheis</option>   
              </select>   
             </div>  
             <div class="form-group">  
               <input type="text" name="tempat_lahir" class="form-control" placeholder="Tempat Lahir" />  
             </div>  
             <div class="form-group">  
               <input type="date" name="tgl_lahir" class="form-control" placeholder="Tanggal Lahir"/>  
             </div>  
              <div class="form-group">  
               <label for="jenis_kel">Jenis Kelamin: </label>   
     <label><input type="radio" name="jenis_kel" value="laki-laki"> Laki-laki</label>   
     <label><input type="radio" name="jenis_kel" value="perempuan"> Perempuan</label>   
             <div class="form-group">  
               <input type="submit" name="daftar" class="btnContact" value="Submit" />  
             </div>  
           </div>  
          </div>  
           <div class="col-md-6">  
             <div class="form-group">  
               <textarea name="alamat"class="form-control" placeholder="Alamat" ></textarea>   
             </div>  
              <div class="form-group">  
               <input type="text" name="provinsi" class="form-control" placeholder="Provinsi" />  
             </div>  
              <div class="form-group">  
               <input type="text" name="kota" class="form-control" placeholder="Kota" />  
             </div>  
             <div class="form-group">  
               <input type="tel" name="telepon" class="form-control" placeholder="Telepon" />  
             </div>  
             <div class="form-group">  
               <input type="text" name="sekolah_asal" class="form-control" placeholder="Nama Sekolah" />  
             </div>  
               <div class="form-group">  
               <select name="sekolah_pilihan" class="form-control">   
      <option>SMAN 2 Surabaya</option>   
      <option>SMAN 5 Surabaya</option>   
      <option>SMAN 6 Surabaya</option>  
      <option>SMAN 15 Surabaya</option>   
      <option>SMAN 16 Surabaya</option>    
     </select>   
             </div>  
             </div>  
           </div>  
          </form>  
         </div>  
        </body>  
        </html>  

9. form-edit.php
  <?php   
  include("config.php");   
  if( !isset($_GET['nisn']) ){   
   header('Location: list-siswa.php');   
  }   
  $nisn = $_GET['nisn'];   
  // buat query untuk ambil data dari database   
  $sql = "SELECT * FROM siswa WHERE nisn=$nisn";   
  $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>   
  <!DOCTYPE html>   
  <html>   
  <html lang="en">  
  <head>   
   <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
    <title>Pendaftaran Siswa Online</title>   
     <link href="css/bootstrap.min.css" rel="stylesheet">  
    <link rel="stylesheet" type="text/css" href="form.css">   
  </head>   
  <body>  
   <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="index.php?logout='1'">Logout</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>  
   <div class="container contact-form">  
       <div class="contact-image">  
         <img src="PPDB.png">  
       </div>  
       <form method="post" action="proses-edit.php">  
         <h3>Formulir Edit</h3>  
         <div class="row">  
           <div class="col-md-6">  
             <div class="form-group">  
               <input type="text" name="nisn" class="form-control" value="<?php echo $siswa['nisn'] ?>"/>  
             </div>  
             <div class="form-group">  
               <input type="text" name="nik" class="form-control" value="<?php echo $siswa['nik'] ?>" />  
             </div>  
             <div class="form-group">  
               <input type="text" name="nama_lengkap" class="form-control" value="<?php echo $siswa['nama_lengkap'] ?>"/>  
             </div>  
             <div class="form-group">  
              <?php $agama = $siswa['agama']; ?>   
               <select name="agama" class="form-control">   
               <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>   
             </div>  
             <div class="form-group">  
               <input type="text" name="tempat_lahir" class="form-control" value="<?php echo $siswa['tempat_lahir'] ?>"/>  
             </div>  
             <div class="form-group">  
               <input type="date" name="tgl_lahir" class="form-control" value="<?php echo $siswa['tgl_lahir'] ?>"/>  
             </div>  
              <div class="form-group">  
               <label for="jenis_kel">Jenis Kelamin: </label>   
               <?php $jenis_kel = $siswa['jenis_kel']; ?>   
     <label><input type="radio" name="jenis_kel" value="laki-laki" <?php echo ($jenis_kel == 'laki-laki') ? "checked": "" ?>> Laki-laki</label>   
     <label><input type="radio" name="jenis_kel" value="perempuan" <?php echo ($jenis_kel == 'perempuan') ? "checked": "" ?>> Perempuan</label>   
             <div class="form-group">  
               <input type="submit" name="simpan" class="btnContact" value="Save" />  
             </div>  
           </div>  
          </div>  
           <div class="col-md-6">  
             <div class="form-group">  
               <textarea name="alamat"class="form-control"> <?php echo $siswa['alamat'] ?></textarea>   
             </div>  
              <div class="form-group">  
               <input type="text" name="provinsi" class="form-control" value="<?php echo $siswa['provinsi'] ?>" />  
             </div>  
              <div class="form-group">  
               <input type="text" name="kota" class="form-control" value="<?php echo $siswa['kota'] ?>" />  
             </div>  
             <div class="form-group">  
               <input type="tel" name="telepon" class="form-control"value="<?php echo $siswa['telepon'] ?>" />  
             </div>  
             <div class="form-group">  
               <input type="text" name="sekolah_asal" class="form-control" value="<?php echo $siswa['sekolah_asal'] ?>"/>  
             </div>  
               <div class="form-group">  
               <?php $sekolah_pilihan = $siswa['sekolah_pilihan']; ?>   
               <select name="sekolah_pilihan" class="form-control">   
     <option <?php echo ($sekolah_pilihan == 'SMAN 2 Surabaya') ? "selected": "" ?>>SMAN 2 Surabaya</option>   
      <option <?php echo ($sekolah_pilihan == 'SMAN 5 Surabaya') ? "selected": "" ?>>SMAN 5 Surabaya</option>   
      <option <?php echo ($sekolah_pilihan == 'SMAN 6 Surabaya') ? "selected": "" ?>>SMAN 6 Surabaya</option>   
      <option <?php echo ($sekolah_pilihan == 'SMAN 15 Surabaya') ? "selected": "" ?>>SMAN 15 Surabaya</option>   
      <option <?php echo ($sekolah_pilihan == 'SMAN 16 Surabaya') ? "selected": "" ?>>SMAN 16 Surabaya</option>    
     </select>   
             </div>  
             </div>  
           </div>  
          </form>  
         </div>  
        </body>  
        </html>  

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

11. proses-edit.php
 <?php   
  include("config.php");   
  // cek apakah tombol simpan sudah diklik atau blum?   
  if(isset($_POST['simpan'])){   
   // ambil data dari formulir   
   $nisn = $_POST['nisn'];   
   $nik = $_POST['nik'];  
   $nama_lengkap = $_POST['nama_lengkap'];  
   $agama = $_POST['agama'];   
   $tempat_lahir = $_POST['tempat_lahir'];  
   $tgl_lahir = $_POST['tgl_lahir'];  
   $jenis_kel = $_POST['jenis_kel'];   
   $alamat = $_POST['alamat'];   
   $provinsi = $_POST['provinsi'];   
   $kota = $_POST['kota'];   
   $telepon = $_POST['telepon'];  
   $sekolah_asal = $_POST['sekolah_asal'];   
   $sekolah_pilihan = $_POST['sekolah_pilihan'];    
   // buat query update   
   $sql = "UPDATE siswa SET nik='$nik',nama_lengkap='$nama_lengkap',agama='$agama',tempat_lahir='$tempat_lahir',tgl_lahir='$tgl_lahir',jenis_kel='$jenis_kel',alamat='$alamat',provinsi='$provinsi',kota='$kota',telepon='$telepon',sekolah_asal='$sekolah_asal',sekolah_pilihan='$sekolah_pilihan' WHERE nisn=$nisn";   
   $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...");   
  }   
  ?>   

12. proses-pendaftaran.php
  <?php   
  include("config.php");   
  if(isset($_POST['daftar'])){   
   // ambil data dari formulir   
   $nisn = $_POST['nisn'];   
   $nik = $_POST['nik'];  
   $nama_lengkap = $_POST['nama_lengkap'];  
   $agama = $_POST['agama'];   
   $tempat_lahir = $_POST['tempat_lahir'];  
   $tgl_lahir = $_POST['tgl_lahir'];  
   $jenis_kel = $_POST['jenis_kel'];   
   $alamat = $_POST['alamat'];   
   $provinsi = $_POST['provinsi'];   
   $kota = $_POST['kota'];   
   $telepon = $_POST['telepon'];  
   $sekolah_asal = $_POST['sekolah_asal'];   
   $sekolah_pilihan = $_POST['sekolah_pilihan'];   
   // buat query   
   $sql = "INSERT INTO siswa (nisn,nik,nama_lengkap,agama,tempat_lahir,tgl_lahir,jenis_kel,alamat,provinsi,kota,telepon,sekolah_asal,sekolah_pilihan) VALUE ('$nisn','$nik','$nama_lengkap','$agama','$tempat_lahir','$tgl_lahir','$jenis_kel','$alamat','$provinsi','$kota','$telepon','$sekolah_asal','$sekolah_pilihan')";   
   $query = mysqli_query($db, $sql);   
   // apakah query simpan berhasil?   
   if( $query ) {   
    header('Location: home.php?status=sukses');   
   } else {   
    header('Location: home.php?status=gagal');   
   }   
  } else {   
   die("Akses dilarang...");   
  }   
  ?>   

13. index.php
 <?php    
  session_start();    
  if (!isset($_SESSION['nisn'])) {   
     $_SESSION['msg'] = "You must log in first";   
     header('location: login.php');   
  }   
  if (isset($_GET['logout'])) {   
     session_destroy();   
     unset($_SESSION['nisn']);   
     header("location: login.php");   
  }   
  ?>   
  <!DOCTYPE html>   
 <html lang="en">  
  <head>   
   <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
    <title>Pendaftaran Siswa Online</title>   
     <link href="css/bootstrap.min.css" rel="stylesheet">  
 <!--    <link rel="stylesheet" type="text/css" href="style.css">  -->  
  </head>   
  <body>   
    <!-- Navigation -->  
   <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="index.php?logout='1'">Logout</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>  
 <!-- <div class="header">   
    <h2>Home Page</h2>   
  </div> -->   
 <!-- <div class="content"> -->   
     <!-- notification message -->   
     <?php if (isset($_SESSION['success'])) : ?>   
   <div class="error success" >   
      <h3>   
    <?php    
       echo $_SESSION['success'];    
       unset($_SESSION['success']);   
    ?>   
      </h3>   
   </div>   
     <?php endif ?>   
   <!-- logged in user information -->   
   <?php if (isset($_SESSION['nisn'])) : ?>   
   <div class="container bg-light" style="text-align: center;">   
     <h1>Selamat Datang <?php echo $_SESSION['nisn']; ?></h1> <br> <br>  
      <div>  
     <a href="form-daftar.php" type="button" class="btn btn-primary bg-blue"> <h3>Isi Data</h3></a>  
     <a href="view.php" type="button" class="btn btn-primary bg-blue"> <h3>Lihat dan Download Data</h3></a>  
     <a href="list-siswa.php" type="button" class="btn btn-primary bg-blue"> <h3>Edit/Hapus Data</h3></a>  
     </div>  
     </div>   
   <?php endif ?>   
  </div>   
  </body>   
  </html>   

14. list-siswa.php
 <?php include("config.php"); ?>   
  <!DOCTYPE html>   
  <html>   
 <html lang="en">  
  <head>   
   <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
    <title>Pendaftaran Siswa Online</title>   
     <link href="css/bootstrap.min.css" rel="stylesheet">  
    <link rel="stylesheet" type="text/css" href="form.css">   
  </head>   
  <body>  
   <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="index.php?logout='1'">Logout</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>   
   <style type="text/css">    
   body {   
    background: gainsboro;   
    font-family: sans-serif;   
   }   
   .login {   
    padding: 1em;   
    margin: 2em auto;   
    width: 30em;   
    background: #fff;   
    border-radius: 3px;   
   }   
   label {   
    font-size: 10pt;   
    color: #555;   
   }   
   textarea {   
    padding: 8px;   
    width: 95%;   
    background: #efefef;   
    border: 0;   
    font-size: 10pt;   
    margin: 6px 0px;   
   }   
   .tombol {   
    background: #7A0000;   
    color: #fff;   
    border: 0;   
    padding: 5px 8px;   
   }   
  </head>   
  </style>   
  <body>   
    <header>   
     <br>  
    <h2 align="center">Formulir Pendaftaran Siswa Baru 2019</h2>   
    </header>   
    <div class="login">   
    <fieldset>   
    <p>   
    <?php   
    $sql = "SELECT * FROM siswa";   
    $query = mysqli_query($db, $sql);   
    $siswa = mysqli_fetch_array($query);   
    echo "<p align='center'> Formulir Pendaftaran Siswa Baru 2019</p>";   
    echo " <p align='center'> SMA Daerah Surabaya</p>";   
    echo "__________________________________________________";   
    echo "<br />";   
    echo "<br />";   
    echo "<strong>NISN</strong><br>";   
    echo $siswa['nisn']; echo "<br>";   
    echo "<br />";   
    echo "<strong>NIK</strong><br>";   
    echo $siswa['nik']; echo "<br>";   
    echo "<br />";  
    echo "<strong>Nama Lengkap</strong><br>";   
    echo $siswa['nama_lengkap']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Agama</strong><br>";   
    echo $siswa['agama']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Tempat Lahir</strong><br>";   
    echo $siswa['tempat_lahir']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Tanggal Lahir</strong><br>";   
    echo $siswa['tgl_lahir']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Jenis Kelamin</strong><br>";   
    echo $siswa['jenis_kel']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Alamat</strong><br>";   
    echo $siswa['alamat']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Provinsi</strong><br>";   
    echo $siswa['provinsi']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Kota</strong><br>";   
    echo $siswa['kota']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Telepon</strong><br>";   
    echo $siswa['telepon']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Sekolah Asal</strong><br>";   
    echo $siswa['sekolah_asal']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Sekolah Pilihan</strong><br>";   
    echo $siswa['sekolah_pilihan']; echo "<br>";   
    echo "<br /></br>";   
    echo "<td>";   
    echo "<a href='form-edit.php?nisn=".$siswa['nisn']."'>Edit</a> | ";   
    echo "<a href='hapus.php?nisn=".$siswa['nisn']."'>Hapus</a>";   
    echo "</td>";   
    ?>   
    </p>   
  </html>    
  </body>   

15. view.php
 <?php include("config.php"); ?>   
  <!DOCTYPE html>   
  <html>   
  <html lang="en">  
  <head>   
   <meta charset="utf-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">  
   <meta name="description" content="">  
   <meta name="author" content="">  
    <title>Pendaftaran Siswa Online</title>   
     <link href="css/bootstrap.min.css" rel="stylesheet">  
    <link rel="stylesheet" type="text/css" href="form.css">   
  </head>   
  <body>  
   <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">  
    <div class="container">  
     <a class="navbar-brand" href="index.php">Pendaftaran Siswa Online</a>  
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">  
      <span class="navbar-toggler-icon"></span>  
     </button>  
     <div class="collapse navbar-collapse" id="navbarResponsive">  
      <ul class="navbar-nav ml-auto">  
       <li class="nav-item">  
        <a class="nav-link" href="index.php?logout='1'">Logout</a>  
       </li>  
      </ul>  
     </div>  
    </div>  
   </nav>   
   <style type="text/css">    
   body {   
    background: gainsboro;   
    font-family: sans-serif;   
   }   
   .login {   
    padding: 1em;   
    margin: 2em auto;   
    width: 30em;   
    background: #fff;   
    border-radius: 3px;   
   }   
   label {   
    font-size: 10pt;   
    color: #555;   
   }   
   textarea {   
    padding: 8px;   
    width: 95%;   
    background: #efefef;   
    border: 0;   
    font-size: 10pt;   
    margin: 6px 0px;   
   }   
   .tombol {   
    background: #7A0000;   
    color: #fff;   
    border: 0;   
    padding: 5px 8px;   
   }   
  </head>   
  </style>   
  <body>   
    <header>   
         <br>  
    <h2 align="center">Formulir Pendaftaran Siswa Baru 2019</h2>   
    </header>   
    <div class="login">   
    <fieldset>   
    <p>   
    <?php   
    $sql = "SELECT * FROM siswa";   
    $query = mysqli_query($db, $sql);   
    $siswa = mysqli_fetch_array($query);   
    echo "<p align='center'> Formulir Pendaftaran Siswa Baru 2019</p>";   
    echo " <p align='center'> SMA Daerah Surabaya</p>";   
    echo "__________________________________________________";   
    echo "<br />";   
    echo "<br />";   
    echo "<strong>NISN</strong><br>";   
    echo $siswa['nisn']; echo "<br>";   
    echo "<br />";   
    echo "<strong>NIK</strong><br>";   
    echo $siswa['nik']; echo "<br>";   
    echo "<br />";  
    echo "<strong>Nama Lengkap</strong><br>";   
    echo $siswa['nama_lengkap']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Agama</strong><br>";   
    echo $siswa['agama']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Tempat Lahir</strong><br>";   
    echo $siswa['tempat_lahir']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Tanggal Lahir</strong><br>";   
    echo $siswa['tgl_lahir']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Jenis Kelamin</strong><br>";   
    echo $siswa['jenis_kel']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Alamat</strong><br>";   
    echo $siswa['alamat']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Provinsi</strong><br>";   
    echo $siswa['provinsi']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Kota</strong><br>";   
    echo $siswa['kota']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Telepon</strong><br>";   
    echo $siswa['telepon']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Sekolah Asal</strong><br>";   
    echo $siswa['sekolah_asal']; echo "<br>";   
    echo "<br />";   
    echo "<strong>Sekolah Pilihan</strong><br>";   
    echo $siswa['sekolah_pilihan']; echo "<br>";   
    echo "<br /></br>";   
    echo "<td>";   
    ?>   
    </p>   
    <form method="post" action="download.php">   
    <input type="submit" name="download" class="btn btn-success" value="Download" />   
  </html>    
  </body>   

16. form.css
 body{  
   background: -webkit-linear-gradient(left, #0072ff, #00c6ff);  
 }  
 .contact-form{  
   background: #fff;  
   margin-top: 10%;  
   margin-bottom: 5%;  
   width: 70%;  
 }  
 .contact-form .form-control{  
   border-radius:1rem;  
 }  
 .contact-image{  
   text-align: center;  
 }  
 .contact-image img{  
   border-radius: 8rem;  
   width: 12%;  
   margin-top: -3%;  
 }  
 .contact-form form{  
   padding: 14%;  
 }  
 .contact-form form .row{  
   margin-bottom: -7%;  
 }  
 .contact-form h3{  
   margin-bottom: 8%;  
   margin-top: -10%;  
   text-align: center;  
   color: #0062cc;  
 }  
 .contact-form .btnContact {  
   width: 50%;  
   border: none;  
   border-radius: 1rem;  
   padding: 1.5%;  
   background: #dc3545;  
   font-weight: 600;  
   color: #fff;  
   cursor: pointer;  
 }  
 .btnContactSubmit  
 {  
   width: 50%;  
   border-radius: 1rem;  
   padding: 1.5%;  
   color: #fff;  
   background-color: #0062cc;  
   border: none;  
   cursor: pointer;  
 }  

Hasil dari web saya:

Berikut halaman register

Halaman Log In

Setelah itu main page

Mengisi Formulir Pendaftaran Siswa

Mengedit Formulir




Menghapus Data

Download formulir



Terimakasih.


Comments

Popular Posts