-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_jp.php
135 lines (104 loc) · 5.13 KB
/
update_jp.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
if(isset($_GET['id'])){
// ambil id dari url atau method get
$id = $_GET['id'];
// Buat koneksi dengan MySQL
$con = mysqli_connect("localhost","root","","db_berita");
// Check connection
// if (mysqli_connect_errno()) {
// echo "Failed to connect to MySQL: " . mysqli_connect_error();
// exit();
// }else{
// echo '<br>koneksi berhasil';
// }
// TABEL Jenjang Pendidikan
$sql = "SELECT * FROM kp_jenjangpendidikan WHERE id='$id'";
if ($result = mysqli_query($con, $sql)) {
// echo "<br>data tersedia";
while($data = mysqli_fetch_assoc($result)) {
$no_ = $data['no_'];
$jenjang_pendidikan = $data['jenjang_pendidikan'];
$jumlah = $data['jumlah'];
$presentase = $data['presentase'];
}
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
//echo print_r($data);
//die();
mysqli_close($con);
}
if (isset($_POST['submit'])){
//var_dump($_POST);
$no_ = $_POST['no_'];
$jenjang_pendidikan = $_POST['jenjang_pendidikan'];
$jumlah = $_POST['jumlah'];
$presentase = $_POST['presentase'];
// Buat koneksi dengan MySQL
$con = mysqli_connect("localhost","root","","db_berita");
// Check connection
// if (mysqli_connect_errno()) {
// echo "Failed to connect to MySQL: " . mysqli_connect_error();
// exit();
// }else{
// echo '<br>koneksi berhasil';
// }
$sql = ("UPDATE kp_jenjangpendidikan SET no_='$no_',jenjang_pendidikan='$jenjang_pendidikan',jumlah='$jumlah',presentase='$presentase' WHERE id='$id'");
if (mysqli_query($con, $sql)) {
echo "<br>Data berhasil diupdate";
//kalau berhasil pake perintah redirect kembali ke halaman berita.php
//kembali ke halaman sebelumnya
header("Location: ./personil.php", TRUE, 301);
exit();
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
mysqli_close($con);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>update data</title>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<!-- icon bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
</head>
<body style="background-color: #f2f2fc;">
<section class="vh-2" style="padding-bottom: 100px;">
<div class="container py-1 h-100">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col col-lg-9 col-xl-7">
<div class="card shadow rounded-3 mt-5">
<div class="card-body p-4">
<h2>KOMPOSISI PEGAWAI MENURUT JENJANG PENDIDIKAN</h2>
<?php if(isset($_GET['id'])): ?>
<form action="" method="post" enctype="multipart/form-data">
<label for="exampleFormControlInput1" class="form-label mt-3">No :</label>
<input type="text" name="no_" class="form-control mb-3" value="<?php echo $no_; ?>">
<label for="exampleFormControlInput1" class="form-label">Jenjang Pendidikan :</label>
<input type="text" name="jenjang_pendidikan" class="form-control mb-3" value="<?php echo $jenjang_pendidikan; ?>">
<label for="exampleFormControlInput1" class="form-label">Jumlah :</label>
<input type="text" name="jumlah" class="form-control mb-3" value="<?php echo $jumlah; ?>">
<label for="exampleFormControlInput1" class="form-label">Presentase :</label>
<input type="text" name="presentase" class="form-control mb-3" value="<?php echo $presentase; ?>">
<div class="row justify-content-start mt-5">
<input class="btn btn-danger me-3 col-md-4 col-sm-12" style="width: 90px;" type="reset" name="submit" value="Reset">
<input class="btn btn-primary me-2 col-md-4 col-sm-12" style="width: 90px;" type="submit" name="submit" value="Submit">
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>
</html>