Professional Documents
Culture Documents
Nama db =” tes”
Tabel “admin”
Tabel “buku”
Login.php
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
table {
margin-top: 100px;
border-radius: 5px;
background-color: tomato;
color: white;
}
</style>
</head>
<body>
<form method="post" action="proseslogin.php">
<center>
<table>
<tr>
<td colspan="3"><center><b>LOGIN!</b></center></td>
</tr>
<tr>
<td>Username</td>
<td>:</td>
<td><input type="text" name="uname" required="required"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="pword" required="required"></td>
</tr>
<tr>
<td colspan="3"><center><input type="submit" name="X"></center></td>
</tr>
</table>
</center>
</form>
</body>
</html>
Proseslogin.php
<?php
include 'koneksi.php';
if (isset($_POST["X"])) {
$uname=$_POST['uname'];
$pword=$_POST['pword'];
$pecah=mysqli_num_rows($sql);
if ($pecah>0) {
session_start();
$_SESSION["user"]=$uname;
echo "<script language=javascript>
window.alert('Login Berhasil');
javascript:document.location='index.php';
</script>";
}else{
echo "<script language=javascript>
window.alert('Login Gagal');
javascript:document.location='login.php';
</script>";
}
}
?>
Koneksi.php
<?php
$host="localhost";
$user="root";
$password="";
$database="tes";
$kons = mysqli_connect($host,$user,$password,$database);
?>
Logout.php
<?php
session_start();
unset($_SESSION);
session_unset();
session_destroy();
header('location:login.php');
?>
Index.php
<?php
include 'koneksi.php';
session_start();
if (empty($_SESSION["user"])) {
echo "<script language=javascript>
window.alert('Maaf Anda Belum Login');
javascript:document.location='login.php';
</script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Halaman Admin</title>
<style type="text/css">
body{
margin:0;
}
.container{
width: 80%;
margin-left: 10%;
margin-top: 1%;
}
.head{
background-color: red;
width: 100%;
height: 150px;
}
.kiri{
background-color: tomato;
width: 30%;
height: 460px;
float: left;
}
.kanan{
float: left;
background-color: grey;
width: 70%;
height: 460px;
}
</style>
</head>
<body>
<div class="container">
<div class="head">
<center>
<form action="cari.php" method="post" target="frameone">
<strong>Pencarian Buku:</strong>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table border="1px">
<tr style="background-color: green;">
<th>ISBN</th>
<th>JUDUL BUKU</th>
<th>PENULIS</th>
<th>PENERBIT</th>
<th>TAHUN RILIS</th>
<th>MENU</th>
</tr>
<?php
include'koneksi.php';
if (isset($_GET['delete'])) {
$idx = $_GET['id'];
mysqli_query($kons, "DELETE FROM buku WHERE Isbn = '$idx'");
echo "<script> alert('Data Terhapus'); document.location='daftarbuku.php'; </script>";
}
</body>
</html>
Cari.php
<?php
include "koneksi.php";
?>
<html>
<link href="framelayout.css" rel="stylesheet" type="text/css" />
<body>
<table class="buku" border="1">
<?php
if (isset($_POST['submit'])) {
$search = $_POST['txtCari'];
}
}
?>
</table>
</body>
</html>
Tambah.php
<?php
if (isset($_POST['judul'])) {
$Isbn = $_POST['Isbn'];
$judul = $_POST['judul'];
$penulis = $_POST['penulis'];
$penerbit = $_POST['penerbit'];
$tahun = $_POST['tahun'];
include 'koneksi.php';
<tr>
<td>Penulis</td>
<td>:</td>
<td><input type="text" name="penulis" required></td>
</tr>
<tr>
<td>Penerbit</td>
<td>:</td>
<td><input type="text" name="penerbit" required></td>
</tr>
<tr>
<td>Tehun Rilis</td>
<td>:</td>
<td><input type="number" name="tahun" required></td>
</tr>
<tr>
<td colspan="3"><button type="submit" style="width: 100%;">+
Tambah</button></td>
</tr>
</table>
</form>
Edit.php
<?php
include 'koneksi.php';
$idx = $_GET['id'];
if (isset($_POST['judul'])) {
$judul = $_POST['judul'];
$penulis = $_POST['penulis'];
$penerbit = $_POST['penerbit'];
$tahun = $_POST['tahun'];
}
?>
<form action="#" method="POST">
<table>
<tr>
<td>Judul</td>
<td>:</td>
<td><input type="text" name="judul" value="<?php echo $data['Judul_Buku'] ?>"
required></td>
</tr>
<tr>
<td>Penulis</td>
<td>:</td>
<td><input type="text" name="penulis" value="<?php echo $data['Penulis'] ?>"
required></td>
</tr>
<tr>
<td>Penerbit</td>
<td>:</td>
<td><input type="text" name="penerbit" value="<?php echo $data['Penerbit'] ?>"
required></td>
</tr>
<tr>
<td>Tehun Rilis</td>
<td>:</td>
<td><input type="number" name="tahun" value="<?php echo $data['Tahun_Rilis'] ?>"
required></td>
</tr>
<tr>
<td colspan="3"><button type="submit" style="width: 100%;">+ Simpan
Perubahan</button></td>
</tr>
</table>
</form>