-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_buku.php
More file actions
66 lines (58 loc) · 1.73 KB
/
Copy pathedit_buku.php
File metadata and controls
66 lines (58 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
// include database connection file
include_once("config.php");
// Check if form is submitted for user update, then redirect to homepage after update
if(isset($_POST['update']))
{
$id_buku = $_POST['id_buku'];
$judul_buku=$_POST['judul_buku'];
$tahun_terbit=$_POST['tahun_terbit'];
$penulis=$_POST['penulis'];
// update user data
$result = mysqli_query($mysqli, "UPDATE buku SET judul_buku='$judul_buku',tahun_terbit='$tahun_terbit',penulis='$penulis' WHERE id_buku=$id_buku");
// Redirect to homepage to display updated user in list
header("Location: index.php");
}
?>
<?php
// Display selected user data based on id
// Getting id from url
$id_buku = $_GET['id_buku'];
// Fetech user data based on id
$result = mysqli_query($mysqli, "SELECT * FROM buku WHERE id_buku=$id_buku");
while($user_data_buku = mysqli_fetch_array($result))
{
$judul_buku = $user_data_buku['judul_buku'];
$tahun_terbit = $user_data_buku['tahun_terbit'];
$penulis = $user_data_buku['penulis'];
}
?>
<html>
<head>
<title>Edit User buku</title>
</head>
<body>
<a href="index.php">Home</a>
<br/><br/>
<form name="update" method="post" action="edit_buku.php">
<table border="0">
<tr>
<td>judul_buku</td>
<td><input type="text" name="judul_buku" value=<?php echo $judul_buku;?>></td>
</tr>
<tr>
<td>tahun_terbit</td>
<td><input type="text" name="tahun_terbit" value=<?php echo $tahun_terbit;?>></td>
</tr>
<tr>
<td>penulis</td>
<td><input type="text" name="penulis" value=<?php echo $penulis;?>></td>
</tr>
<tr>
<td><input type="hidden" name="id_buku" value=<?php echo $_GET['id_buku'];?>></td>
<td><input type="submit" name="update" value="update_buku"></td>
</tr>
</table>
</form>
</body>
</html>