EAS PWEB
Pengerjaan EAS - Membuat PDB dengan Bootstrap
Rancangan Database :
Dokumentasi Implementasi :
auth.php
index.php
register.php
timeline.php
edit.php
prosesedit.php
daftarsekolah.php
prosesdaftar.php
rincian.php
logout.php
Hasil :
Tampilan Edit :
Tampilan Login :
Nama : Kevin Ashil Faadilah
NRP : 05111740000178
Kelas : PWEB - C
terima kasih.
Video Tutorial Penggunaan :
Rancangan Database :
Rancangan Interfaces :
config.php
<?php
$db_host = "localhost";
$db_user = "vashcopw_admin";
$db_pass = "admin_123";
$db_name = "siswa";
try {
//create PDO connection
$db = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
} catch(PDOException $e) {
//show error
die("Terjadi masalah: " . $e->getMessage());
}
auth.php
<?php
session_start();
if(!isset($_SESSION["user"])) header("Location: login.php");
index.php
<?php
require_once("config.php");
if(isset($_POST['login'])){
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
$sql = "SELECT * FROM users WHERE username=:username OR email=:email";
$stmt = $db->prepare($sql);
// bind parameter ke query
$params = array(
":username" => $username,
":email" => $username
);
$stmt->execute($params);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
// jika user terdaftar
if($user){
// verifikasi password
if(password_verify($password, $user["password"])){
// buat Session
session_start();
$_SESSION["user"] = $user;
// login sukses, alihkan ke halaman timeline
header("Location: timeline.php");
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Pendaftaran SMA Negeri Kota Surabaya</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body text-center">
<img class="img img-responsive mb-3" height="60" src="img/kra.png" />
<img class="img img-responsive mb-3" height="60" src="img/kmd.png" />
<h3>Pendaftaran SMA Negeri Kota Surabaya</h3>
<p>Dinas Pendidikan dan Kebudayaan <b>Kota Surabaya</b></p>
</div>
</div>
</div>
<br>
<br>
<div class="col-md-8">
<form action="" method="POST">
<br>
<div class="form-group">
<label for="username">Username</label>
<input class="form-control" type="text" name="username" placeholder="Username atau email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" type="password" name="password" placeholder="Password" />
</div>
<input type="submit" class="btn btn-success btn-block" name="login" value="Masuk" />
</form>
</div>
<div class="col-md-4">
<br>
<br>
<div class="card">
<div class="card-body text-center">
<h4>Belum punya akun?</h4>
<p>Tidak perlu waktu lama untuk mendaftarnya</p>
<a class="btn btn-primary" href="register.php">Daftar</a>
</div>
</div>
<br>
</div>
</div>
</div>
</body>
</html>
register.php
<?php
require_once("config.php");
if(isset($_POST['register'])){
// filter data yang diinputkan
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
// enkripsi password
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
// menyiapkan query
$sql = "INSERT INTO users (name, username, email, password)
VALUES (:name, :username, :email, :password)";
$stmt = $db->prepare($sql);
// bind parameter ke query
$params = array(
":name" => $name,
":username" => $username,
":password" => $password,
":email" => $email
);
// eksekusi query untuk menyimpan ke database
$saved = $stmt->execute($params);
// jika query simpan berhasil, maka user sudah terdaftar
// maka alihkan ke halaman login
if($saved) header("Location: index.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Register</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body text-center">
<img class="img img-responsive mb-3" height="60" src="img/kra.png" />
<img class="img img-responsive mb-3" height="60" src="img/kmd.png" />
<h3>Pendaftaran SMA Negeri Kota Surabaya</h3> <p>Dinas Pendidikan dan Kebudayaan <b>Kota Surabaya</b></p>
</div>
</div>
</div>
<br>
<br>
<div class="col-md-8">
<form action="" method="POST">
<br>
<div class="form-group">
<label for="name">Nama Lengkap</label>
<input class="form-control" type="text" name="name" placeholder="Nama kamu" />
</div>
<div class="form-group">
<label for="username">Username</label>
<input class="form-control" type="text" name="username" placeholder="Username" />
</div>
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" type="email" name="email" placeholder="Alamat Email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" type="password" name="password" placeholder="Password" />
</div>
<input type="submit" class="btn btn-success btn-block" name="register" value="Daftar" />
</form>
</div>
<div class="col-md-4">
<br>
<br>
<div class="card">
<div class="card-body text-center">
<h4>Sudah punya akun?</h4>
<p>Masuk sekarang</p>
<a class="btn btn-primary" href="index.php">Masuk</a>
</div>
</div>
<br>
</div>
</div>
</div>
</body>
</html>
timeline.php
<?php require_once("auth.php"); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Profil Siswa</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row">
<div class="col-md-4">
<div class="card">
<div class="card-body text-center">
<img class="img img-responsive mb-3" height="90" src="img/kra.png" />
<img class="img img-responsive mb-3" height="90" src="img/kmd.png" />
<p>Dinas Pendidikan dan Kebudayaan <b>Kota Surabaya</b></p>
<hr>
<h3><?php echo $_SESSION["user"]["name"] ?></h3>
<p><?php echo $_SESSION["user"]["username"] ?></p>
<p><a class="btn btn-danger" href="logout.php">Logout</a></p>
</div>
</div>
<br>
</div>
<br>
<div class="col-md-8">
<div class="card mb-3">
<div class="card-body">
<h3>Pendaftaran</h3>
Sekolah yang dipilih
<br><b><?php echo $_SESSION["user"]["school2"] ?></b>
<hr>
<a href="daftarsekolah.php" class="btn btn-primary">Daftar</a>
<a href="rincian.php" class="btn btn-success">Rincian</a>
</div>
</div>
<div class="card mb-3">
<div class="card-body">
<h3>Data siswa</h3>
Username
<br><b><?php echo $_SESSION["user"]["username"] ?></b>
<hr>
Email
<br><b><?php echo $_SESSION["user"]["email"] ?></b>
<hr>
Nama
<br><b><?php echo $_SESSION["user"]["name"] ?></b>
<hr>
NISN
<br><b><?php echo $_SESSION["user"]["nisn"] ?></b>
<hr>
Alamat
<br><b><?php echo $_SESSION["user"]["adress"] ?></b>
<hr>
Telepon
<br><b><?php echo $_SESSION["user"]["phone"] ?></b>
<hr>
Sekolah Asal
<br><b><?php echo $_SESSION["user"]["school1"] ?></b>
<hr>
<a href="edit.php" class="btn btn-primary">Edit</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
edit.php
<?php require_once("auth.php"); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Edit Profil</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<a href="timeline.php" class="btn btn-secondary">Kembali</a>
<a href="#" class="btn btn-light">Edit Profil</a>
<br>
<form action="prosesedit.php" method="POST">
<br>
<div class="form-group">
<label for="username">Username</label>
<input class="form-control" type="text" name="username" placeholder="Username atau email" value="<?php echo $_SESSION["user"]["username"] ?>" />
</div>
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" type="text" name="email" placeholder="Email" value="<?php echo $_SESSION["user"]["email"] ?>" />
</div>
<div class="form-group">
<label for="name">Nama</label>
<input class="form-control" type="text" name="name" placeholder="Nama" value="<?php echo $_SESSION["user"]["name"] ?>" />
</div>
<div class="form-group">
<label for="adress">NISN</label>
<input class="form-control" type="text" name="nisn" placeholder="NISN" value="<?php echo $_SESSION["user"]["nisn"] ?>" />
</div>
<div class="form-group">
<label for="adress">Alamat</label>
<input class="form-control" type="text" name="adress" placeholder="Alamat" value="<?php echo $_SESSION["user"]["adress"] ?>" />
</div>
<div class="form-group">
<label for="phone">Telepon</label>
<input class="form-control" type="text" name="phone" placeholder="Telepon" value="<?php echo $_SESSION["user"]["phone"] ?>" />
</div>
<div class="form-group">
<label for="phone">Sekolah Asal</label>
<input class="form-control" type="text" name="school" placeholder="Asal SMP" value="<?php echo $_SESSION["user"]["school1"] ?>" />
</div>
<input type="submit" class="btn btn-success btn-block" name="submit" value="submit" />
</form>
<br>
</div>
<div class="col-md-6">
<!-- isi dengan sesuatu di sini -->
</div>
</div>
</div>
</body>
</html>
prosesedit.php
<?php
include("config.php");
require_once("auth.php");
// cek apakah tombol simpan sudah diklik atau blum?
if(isset($_POST['submit'])){
// ambil data dari formulir
$id = $_POST['id'];
$username = $_POST['username'];
$email = $_POST['email'];
$name = $_POST['name'];
$adress = $_POST['adress'];
$phone = $_POST['phone'];
$school1 = $_POST['school1'];
$nisn = $_POST['nisn'];
// buat query update
$sql = "UPDATE users SET username='$username', email='$email', name='$name', adress='$adress', phone='$phone', school1='$school1' nisn='$nisn' WHERE id=$id";
$query = mysqli_query($db, $sql);
// apakah query update berhasil?
if( $query ) {
// kalau berhasil alihkan ke halaman list-siswa.php
header('Location: timeline.php');
} else {
// kalau gagal tampilkan pesan
die("Gagal menyimpan perubahan...");
}
} else {
die("Akses dilarang...");
}
?>
daftarsekolah.php
<?php require_once("auth.php");
require_once("config.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Daftar Sekolah</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body class="bg-light">
<div class="container mt-5">
<a href="timeline.php" class="btn btn-secondary">Kembali</a>
<a href="#" class="btn btn-light">Daftar SMA</a>
<div class="row">
<div class="col-md-12">
<br>
<div class="card mb-3">
<div class="card-body">
Nama
<br><b><?php echo $_SESSION["user"]["name"] ?></b>
<hr>
NISN
<br><b><?php echo $_SESSION["user"]["nisn"] ?></b>
<hr>
Alamat
<br><b><?php echo $_SESSION["user"]["adress"] ?></b>
<hr>
Telepon
<br><b><?php echo $_SESSION["user"]["phone"] ?></b>
<hr>
Sekolah Asal
<br><b><?php echo $_SESSION["user"]["school1"] ?></b>
<hr>
Pastikan data terisi dengan lengkap dan benar! <a href="edit.php" class="btn btn-primary">Lengkapi</a>
</div>
</div>
<form action="prosesdaftar.php" method="POST">
<div class="form-group has-default">
<label class="form-group has-default" for="school2">Pilih Sekolah </label>
<div class="form-group has-default">
<select name="school2" id="school2" class="form-control">
<option></option>
<option>SMAN 1 Surabaya</option>
<option>SMAN 2 Surabaya</option>
<option>SMAN 5 Surabaya</option>
<option>SMAN 9 Surabaya</option>
<option>SMAN 15 Surabaya</option>
<option>SMAN 16 Surabaya</option></option>
</select>
</div>
<br>
</div>
<input type="submit" name="submit" value="submit" class="btn btn-success btn-block" />
</form>
<br>
</div>
<div class="col-md-6">
<!-- isi dengan sesuatu di sini -->
</div>
</div>
</div>
</body>
</html>
prosesdaftar.php
<?php
// koneksi database
include 'config.php';
// menangkap data yang di kirim dari form
$school2 = $_POST['school2'];
// menginput data ke database
mysqli_query($db,"insert into user (school2) values('$school2')");
// mengalihkan halaman kembali ke index.php
header("location:timeline.php");
?>
rincian.php
<?php require_once("auth.php");
require_once("config.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Rincian</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row">
<div class="col-md-12">
<div class="card mb-3">
<br>
<div class="card-body text-center">
<br>
<img class="img img-responsive mb-3" height="60" src="img/kra.png" />
<img class="img img-responsive mb-3" height="60" src="img/kmd.png" />
<h3>Formulir Pendaftaran</h3>
<p>Dinas Pendidikan Pemuda dan Olahraga <b>Kabupaten Karanganyar</b></p>
</div>
<div class="card-body">
Nama
<br><b><?php echo $_SESSION["user"]["name"] ?></b>
<hr>
NISN
<br><b><?php echo $_SESSION["user"]["nisn"] ?></b>
<hr>
Alamat
<br><b><?php echo $_SESSION["user"]["adress"] ?></b>
<hr>
Telepon
<br><b><?php echo $_SESSION["user"]["phone"] ?></b>
<hr>
Sekolah Asal
<br><b><?php echo $_SESSION["user"]["school1"] ?></b>
<hr>
Sekolah Pilihan
<br><b><?php echo $_SESSION["user"]["school2"] ?></b>
</div>
</div>
<a href="rincian.php" class="btn btn-success"><i class="fa fa-file"></i> Unduh sebagai PDF
</a>
<br>
<br>
</div>
<div class="col-md-6">
<!-- isi dengan sesuatu di sini -->
</div>
</div>
</div>
</body>
</html>
logout.php
<?php
session_start();
session_unset("user");
header("Location: index.php");
Tampilan Unduh Pdf :
Tampilan Edit :
Tampilan Login :
Nama : Kevin Ashil Faadilah
NRP : 05111740000178
Kelas : PWEB - C
terima kasih.
Komentar
Posting Komentar