-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* Reset margin dan padding */ | ||
body, h1, table { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
/* Mengatur font dan warna dasar */ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
color: #333; | ||
} | ||
|
||
/* Styling untuk header */ | ||
h1 { | ||
text-align: center; | ||
margin: 20px 0; | ||
} | ||
|
||
/* Styling untuk tabel */ | ||
table { | ||
width: 80%; | ||
margin: 20px auto; | ||
border-collapse: collapse; | ||
background-color: white; | ||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
th, td { | ||
padding: 12px; | ||
text-align: left; | ||
border: 1px solid #ddd; | ||
} | ||
|
||
th { | ||
background-color: #4CAF50; | ||
color: white; | ||
} | ||
|
||
/* Styling untuk link */ | ||
a { | ||
color: #4CAF50; | ||
text-decoration: none; | ||
} | ||
|
||
a:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
/* Styling untuk form */ | ||
form { | ||
width: 80%; | ||
margin: 20px auto; | ||
background-color: white; | ||
padding: 20px; | ||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
label { | ||
display: block; | ||
margin: 10px 0 5px; | ||
} | ||
|
||
input[type="text"], | ||
input[type="email"] { | ||
width: 100%; | ||
padding: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
} | ||
|
||
button { | ||
background-color: #4CAF50; | ||
color: white; | ||
padding: 10px 15px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
/* Styling untuk tautan kembali */ | ||
a.back-link { | ||
display: block; | ||
text-align: center; | ||
margin: 20px 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
include 'src/koneksi.php'; | ||
|
||
$sql = "SELECT * FROM msib_data"; | ||
$result = $conn->query($sql); | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<link rel="stylesheet" href="css/style.css"> | ||
<head> | ||
<title>Data</title> | ||
</head> | ||
<body> | ||
<h1>Data</h1> | ||
<a href="src/create.php">Tambah Data</a> | ||
<table border="1"> | ||
<tr> | ||
<th>ID</th> | ||
<th>Nama</th> | ||
<th>Email</th> | ||
<th>Aksi</th> | ||
</tr> | ||
<?php while($row = $result->fetch_assoc()): ?> | ||
<tr> | ||
<td><?php echo $row['id']; ?></td> | ||
<td><?php echo $row['nama']; ?></td> | ||
<td><?php echo $row['email']; ?></td> | ||
<td> | ||
<a href="src/update.php?id=<?php echo $row['id']; ?>">Edit</a> | ||
<a href="src/delete.php?id=<?php echo $row['id']; ?>">Hapus</a> | ||
</td> | ||
</tr> | ||
<?php endwhile; ?> | ||
</table> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
include 'koneksi.php'; | ||
|
||
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | ||
$nama = $_POST['nama']; | ||
$email = $_POST['email']; | ||
|
||
$sql = "INSERT INTO msib_data (nama, email) VALUES ('$nama', '$email')"; | ||
|
||
if ($conn->query($sql) === TRUE) { | ||
$_SESSION['message'] = "Data berhasil ditambahkan!"; | ||
header('Location: ../index.php'); | ||
} else { | ||
$_SESSION['message'] = "Error: " . $conn->error; | ||
} | ||
} | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<link rel="stylesheet" href="../css/style.css"> | ||
<head> | ||
<title>Tambah Data</title> | ||
</head> | ||
<body> | ||
<h1>Tambah Data</h1> | ||
<form method="POST" action=""> | ||
Nama: <input type="text" name="nama" required><br> | ||
Email: <input type="email" name="email" required><br> | ||
<input type="submit" value="Tambah"> | ||
</form> | ||
<p><?php if(isset($_SESSION['message'])) echo $_SESSION['message']; ?></p> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
include 'koneksi.php'; | ||
|
||
$id = $_GET['id']; | ||
|
||
$sql = "DELETE FROM msib_data WHERE id = $id"; | ||
|
||
if ($conn->query($sql) === TRUE) { | ||
$_SESSION['message'] = "Data berhasil dihapus!"; | ||
header('Location:../index.php'); | ||
} else { | ||
$_SESSION['message'] = "Error: " . $conn->error; | ||
} | ||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
$host = "localhost"; | ||
$username = "root"; | ||
$db = "msib"; | ||
$password = ""; | ||
|
||
$conn = mysqli_connect($host,$username,$password,$db); | ||
|
||
// if ($conn->connect_error) { | ||
// die("Koneksi gagal: " . $conn->connect_error); | ||
// } else { | ||
// echo "berhasil"; | ||
// } | ||
|
||
|
||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
include 'koneksi.php'; | ||
|
||
$id = $_GET['id']; | ||
$sql = "SELECT * FROM msib_data WHERE id = $id"; | ||
$result = $conn->query($sql); | ||
$row = $result->fetch_assoc(); | ||
|
||
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | ||
$nama = $_POST['nama']; | ||
$email = $_POST['email']; | ||
|
||
$sql = "UPDATE msib_data SET nama='$nama', email='$email' WHERE id=$id"; | ||
|
||
if ($conn->query($sql) === TRUE) { | ||
$_SESSION['message'] = "Data berhasil diupdate!"; | ||
header('Location: ../index.php'); | ||
} else { | ||
$_SESSION['message'] = "Error: " . $conn->error; | ||
} | ||
} | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<link rel="stylesheet" href="../css/style.css"> | ||
<head> | ||
<title>Update Data</title> | ||
</head> | ||
<body> | ||
<h1>Update Data</h1> | ||
<form method="POST" action=""> | ||
Nama: <input type="text" name="nama" value="<?php echo $row['nama']; ?>" required><br> | ||
Email: <input type="email" name="email" value="<?php echo $row['email']; ?>" required><br> | ||
<input type="submit" value="Update"> | ||
</form> | ||
<p><?php if(isset($_SESSION['message'])) echo $_SESSION['message']; ?></p> | ||
</body> | ||
</html> |