EAS Pemrograman Web - I
EAS PEMROGRAMAN WEB
Nama: Anggito Anju Hartawan Manalu
NRP: 5025201216
Kelas: Pemrograman Web C
1. EAS INDIVIDU
a. Deskripsi Aplikasi
- Latar Belakang
ITS memiliki banyak sekali sarana dan prasarana yang disediakan untuk seluruh Civitas Akademik ITS. Misalnya, organisasi-organisasi maupun kepanitiaan senantia menggunakan ruangan-ruangan rapat yang disediakan oleh ITS. Namun sayangnya, sistem peminjamannya masih sangat sulit dan belum mengimplementasikan sistem informasi digital dalam sistemnya.
- Tujuan
Pembuatan aplikasi pemesanan/peminjaman sarana pra-sarana milik ITS diharapkan dapat mempermudah sistem peminjaman sarana prasarana. Aplikasi ini juga bertujuan untuk mempersingkat sistem peminjaman agar lebih singkat dan lebih aman.
b. Perancangan UI
c. Tabel dan Database yang dipakai
Kita akan menggunakan Database MySQL dengan penggunaan tabel sebagai berikut.
d. Algoritma Proses Pada Back-End
1. Proses Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) { | |
header( "Location: ../index.php" ); | |
die(); | |
} | |
include("../config.php"); | |
session_start(); | |
if( isset($_POST['submit']) ) { | |
// cek username password | |
$username = $_POST['username']; | |
$password = $_POST['password']; | |
$sql = " | |
SELECT * FROM Akun | |
WHERE username= _utf8 '$username' COLLATE utf8_bin AND | |
password= _utf8 '$password' COLLATE utf8_bin; | |
"; | |
$result = mysqli_query($database, $sql); | |
// cek apakah akun ditemukan | |
if($result->num_rows == 1) { | |
$formatted_result = mysqli_fetch_assoc($result); | |
// cek tipe akun | |
$tipe_akun = $formatted_result['tipe_akun']; | |
// set session | |
$_SESSION['username'] = $username; | |
// jika admin, arahkan ke admin page | |
if($tipe_akun == "admin") { | |
header("Location: ../res/admin.php"); | |
} | |
// jika user, arahkan ke landing page | |
else if($tipe_akun == "user") { | |
header("Location: ../res/home.php?login=success"); | |
} | |
// jika not defined, kembalikan ke login page => error | |
else { | |
header("Location: ../res/login.php?error=true"); | |
} | |
} | |
// jika tidak ditemukan, autentikasi salah | |
else { | |
header("Location:../res/login.php?auth=failed"); | |
} | |
} | |
?> |
2. Proses Logout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) { | |
header( "Location: ../index.php" ); | |
die(); | |
} | |
include("../config.php"); | |
session_start(); | |
session_unset(); | |
session_destroy(); | |
header("Location: ../index.php?logout=true"); | |
?> |
3. Proses Register
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) { | |
header( "Location: ../index.php" ); | |
die(); | |
} | |
include("../config.php"); | |
session_start(); | |
// cek jika data sudah di submit | |
if( isset($_POST['submit']) ) { | |
// ambil data dr formulir | |
$namaDepan = $_POST['namaDepan']; | |
$namaBelakang = $_POST['namaBelakang']; | |
$username = $_POST['username']; | |
$password = $_POST['password']; | |
$retype_password = $_POST['retype_password']; | |
$email = $_POST['email']; | |
$noTelp = $_POST['noTelp']; | |
$nip = $_POST['nip']; | |
$jabatan = $_POST['jabatan']; | |
$tmp_nama_foto = $_FILES['foto']['name']; | |
$tmp_file_dir = $_FILES['foto']['tmp_name']; | |
// cek kesamaan password | |
if($password != $retype_password) { | |
header("Location: ../res/register.php?retype=failed"); | |
exit(); | |
} | |
// cek ketersediaan username | |
$sqlUsername = " | |
SELECT username | |
FROM akun | |
WHERE username= _utf8 '$username' COLLATE utf8_bin; | |
"; | |
$resultUsername = mysqli_query($database, $sqlUsername); | |
// jika username sudah dipakai | |
if(mysqli_fetch_assoc($resultUsername)) { | |
// tolak | |
header("Location: ../res/register.php?username=unavail"); | |
exit(); | |
} | |
// jika username belum dipakai | |
// ambil id terakhir | |
$sqlLastID = " | |
SELECT MAX(id_akun) AS 'lastID' FROM akun; | |
"; | |
$resultLastID = mysqli_query($database, $sqlLastID); | |
$lastID = $resultLastID->fetch_assoc()['lastID'] + 1; | |
// proses nama foto | |
$nama_foto = date('dmYHis')."-".$tmp_nama_foto; | |
// file dir foto | |
$path_foto = "../uploaded_files/img/foto_tanda_pengenal/".$nama_foto; | |
// cek apakah foto sudah terupload pada database | |
if(move_uploaded_file($tmp_file_dir, $path_foto)) { | |
// buat query | |
$sqlInsert = " | |
INSERT INTO akun(id_akun, tipe_akun, akun_dibuat, nama_depan, nama_belakang, username, password, email, no_telp, nip, jabatan, foto_tanda_pengenal) | |
VALUES ($lastID, 'user', NOW(), '$namaDepan', '$namaBelakang', '$username', '$password', '$email', '$noTelp', '$nip', '$jabatan', '$path_foto'); | |
"; | |
$resultInsert = mysqli_query($database, $sqlInsert); | |
if($resultInsert) { | |
$_SESSION['username'] = $username; | |
header("Location: ../res/home.php?register=success"); | |
} | |
else { | |
header("Location: ../res/register.php?register=failed"); | |
} | |
} | |
} | |
?> |
4. Proses List Ruangan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) { | |
header( "Location: ../index.php" ); | |
die(); | |
} | |
include("../config.php"); | |
// ambil data list ruangan | |
$sqlRuangan = " | |
SELECT jenis_ruangan, nama_ruangan, kuota_ruangan | |
FROM ruangan | |
WHERE status_operasional=1; | |
"; | |
$resultListRuangan = mysqli_query($database, $sqlRuangan); | |
?> |
5. Proses Pemesanan Ruangan
2. EAS KELOMPOK - IMPLEMENTASI FULL-STACK
Anggota Kelompok:
1. Anggito Anju Hartawan Manalu - 5025201216
2. Ahmad Ibnu Malik Rahman - 5025201
Link Website: simpruits.my.id
3. EAS KELOMPOK - DOKUMENTASI
Link Video Demo: https://youtu.be/uHj05tua11c
Dokumentasi Website
Landing Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) { | |
header( "Location: ../index.php" ); | |
die(); | |
} | |
include("../config.php"); | |
session_start(); | |
// jika username tidak ada -> suruh login | |
if(!isset($_SESSION['username'])) { | |
header("Location: ../index.php"); | |
exit(); | |
} | |
if(isset($_POST['submit'])) { | |
// ambil data dari formulir | |
$tanggalPemakaian = $_POST['tanggalPemakaian']; | |
$jamMulai = $tanggalPemakaian." ".$_POST['jamMulai'].":00"; | |
$jamSelesai = $tanggalPemakaian." ".$_POST['jamSelesai'].":00"; | |
$username = $_POST['username']; | |
$namaRuangan = $_POST['namaRuangan']; | |
// Set Pemesanan pada database | |
// get id terakhir | |
$sqlLastID = " | |
SELECT MAX(id_pesanan_ruangan) AS 'lastID' FROM pesanan_ruangan; | |
"; | |
$resultLastID = mysqli_query($database, $sqlLastID); | |
$lastID = $resultLastID->fetch_assoc()['lastID'] + 1; | |
// get akun id | |
$sqlAkunID = " | |
SELECT id_akun FROM akun WHERE username='$username'; | |
"; | |
$resultAkunID = mysqli_query($database, $sqlAkunID); | |
$akunID = $resultAkunID->fetch_assoc()['id_akun']; | |
// get ruangan id | |
$sqlRuanganID = " | |
SELECT id_ruangan FROM ruangan WHERE nama_ruangan='$namaRuangan'; | |
"; | |
$resultRuanganID = mysqli_query($database, $sqlRuanganID); | |
$ruanganID = $resultRuanganID->fetch_assoc()['id_ruangan']; | |
// Buat Query | |
$sqlPesananRuangan = " | |
INSERT INTO pesanan_ruangan VALUES($lastID, 'Pengecekan Dokumen', 0, '$jamMulai', '$jamSelesai', $akunID, $ruanganID); | |
"; | |
$resultPesananRuangan = mysqli_query($database, $sqlPesananRuangan); | |
if($resultPesananRuangan) { | |
header("Location: ../res/home.php?pemesanan=success"); | |
exit(); | |
} | |
else { | |
header("Location: ../res/buat_pesanan_ruangan.php?pemesanan=failed"); | |
exit(); | |
} | |
} | |
?> |
Komentar
Posting Komentar