-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.php
150 lines (132 loc) · 6.03 KB
/
edit.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
include "config.php";
include "navbar.php";
session_start();
if (!isset($_SESSION['username'])) {
header("Location: login.php");
}
$no = $_GET['editid'];
$sql = "select * from `siswa` where no=$no";
$result = mysqli_query($koneksi, $sql);
$row = mysqli_fetch_assoc($result);
$nis = $row['nis'];
$nama = $row['nama'];
$alamat = $row['alamat'];
$kota = $row['kota'];
$kodepos = $row['kodepos'];
$gender = $row['jenisKelamin'];
$umur = $row['umur'];
$agama = $row['agama'];
$ibu = $row['ibu'];
$bapak = $row['bapak'];
$golongandarah = $row['golonganDarah'];
if (isset($_POST['edit'])) {
$nis = $_POST['nis'];
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$kota = $_POST['kota'];
$kodepos = $_POST['kode_pos'];
$gender = $_POST['gender'];
$umur = $_POST['umur'];
$agama = $_POST['agama'];
$ibu = $_POST['ibu'];
$bapak = $_POST['ayah'];
$darah = $_POST['golonganDarah'];
$sql = "update `siswa` set no=$no,nis='$nis',nama='$nama',alamat='$alamat',
kota='$kota',kodepos='$kodepos',jenisKelamin='$gender',umur='$umur',agama='$agama',
ibu='$ibu',bapak='$bapak',golonganDarah='$darah' where no=$no";
$result = mysqli_query($koneksi, $sql);
if ($result) {
echo "<script> alert('Data Siswa Berhasil Disimpan');
document.location='list.php';</script>";
} else {
die(mysqli_error($koneksi));
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Pendaftaran Siswa Baru</title>
<link rel="stylesheet" href="css/form.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="container">
<div class="title">Edit Data Siswa</div>
<div class="content">
<form name="formPendaftaran" action="" method="post" onsubmit="return validateForm()">
<div class="user-details">
<div class="input-box">
<span class="details">NIS</span>
<input name="nis" type="number" placeholder="Masukan NIS" value="<?php echo $nis; ?>">
</div>
<div class="input-box">
<span class="details">Nama Lengkap</span>
<input name="nama" type="text" placeholder="Masukan Nama Lengkap" value="<?php echo $nama; ?>">
</div>
<div class="input-box">
<span class="details">Alamat lengkap</span>
<input name="alamat" type="text" placeholder="Masukkan Alamat Lengkap" value="<?php echo $alamat; ?>">
</div>
<div class="input-box">
<span class="details">Kota</span>
<input name="kota" type="text" placeholder="Masukan Kota" value="<?php echo $kota; ?>">
</div>
<div class="input-box">
<span class="details">Kode Pos</span>
<input name="kode_pos" type="number" placeholder="Kode Pos" value="<?php echo $kodepos; ?>">
</div>
<div class="input-box">
<span class="details">Umur</span>
<input name="umur" type="number" placeholder="Masukan Umur" value="<?php echo $umur; ?>">
</div>
<div class="input-box">
<span class="details">Agama</span>
<select id="agama" name="agama" required>
<option id="option-list" value="">Pilih Agama</option>
<option <?php echo ($agama == 'Islam') ? "selected" : ""; ?>>Islam</option>
<option <?php echo ($agama == 'Kristen') ? "selected" : ""; ?>>Kristen</option>
<option <?php echo ($agama == 'Hindu') ? "selected" : ""; ?>>Hindu</option>
<option <?php echo ($agama == 'Budha') ? "selected" : ""; ?>>Budha</option>
</select>
</div>
<div class="input-box">
<span class="details">Golongan Darah</span>
<input name="golonganDarah" type="text" placeholder="Masukkan Golongan Darah" value="<?php echo $golongandarah; ?>">
</div>
<div class="input-box">
<span class="details">Nama Ayah Kandung</span>
<input name="ayah" type="text" placeholder="Masukkan Nama Ayah Kandung" value="<?php echo $bapak; ?>">
</div>
<div class="input-box">
<span class="details">Nama Ibu Kandung</span>
<input name="ibu" type="text" placeholder="Masukkan Nama Ibu Kandung" value="<?php echo $ibu ?>">
</div>
</div>
<div class="gender-details">
<input type="radio" name="gender" value="Laki - Laki" id="dot-1">
<input type="radio" name="gender" value="Perempuan" id="dot-2">
<span class="gender-title">Jenis Kelamin</span>
<div class="category">
<label for="dot-1">
<span class="dot one"></span>
<span class="gender">Laki - Laki</span>
</label>
</div>
<div class="category">
<label for="dot-2">
<span class="dot two"></span>
<span class="gender">Perempuan</span>
</label>
</div>
</div>
<div class="button">
<input type="submit" name="edit" value="UPDATE">
</div>
</form>
</div>
</div>
</body>
</html>