Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bagas Rizki Aji Wijaya
Data Penduduk
Commits
bfe2d099
Commit
bfe2d099
authored
2 years ago
by
Bagas Rizki Aji Wijaya
Browse files
Options
Download
Email Patches
Plain Diff
finish crud
parent
40e45e1c
main
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
edit.php
+428
-0
edit.php
index.php
+14
-3
index.php
penduduk.php
+14
-0
penduduk.php
with
456 additions
and
3 deletions
+456
-3
edit.php
0 → 100644
View file @
bfe2d099
This diff is collapsed.
Click to expand it.
index.php
View file @
bfe2d099
...
...
@@ -4,12 +4,14 @@ include('penduduk.php');
if
(
isset
(
$_POST
[
'uploadData'
]))
{
$penduduk
=
new
Penduduk
(
$_POST
[
'nik'
],
$_POST
[
'nama'
],
$_POST
[
'gender'
],
$_POST
[
'alamat'
],
$_POST
[
'status'
],
$_POST
[
'pekerjaan'
],
$_POST
[
'warga'
],
$_POST
[
'tempatLahir'
],
$_POST
[
'tanggalLahir'
],
$_POST
[
'darah'
]);
$penduduk
->
tambahData
(
$koneksi
);
}
else
if
(
isset
(
$_POST
[
'updateData'
]))
{
$penduduk
=
new
Penduduk
(
$_POST
[
'nik'
],
$_POST
[
'nama'
],
$_POST
[
'gender'
],
$_POST
[
'alamat'
],
$_POST
[
'status'
],
$_POST
[
'pekerjaan'
],
$_POST
[
'warga'
],
$_POST
[
'tempatLahir'
],
$_POST
[
'tanggalLahir'
],
$_POST
[
'darah'
]);
$penduduk
->
updateData
(
$koneksi
);
}
else
if
(
isset
(
$_POST
[
'delete'
]))
{
$penduduk
->
hapusData
(
$koneksi
,
$_POST
[
'id'
]);
}
else
{
$penduduk
=
new
Penduduk
(
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
);
}
if
(
isset
(
$_POST
[
'delete'
]))
{
$penduduk
->
hapusData
(
$koneksi
,
$_POST
[
'id'
]);
}
?>
<!DOCTYPE html>
<html
lang=
"en"
>
...
...
@@ -393,6 +395,7 @@ if (isset($_POST['delete'])) {
<th>
Tempat, Tanggal Lahir
</th>
<th>
Golonan Darah
</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
...
...
@@ -418,6 +421,14 @@ if (isset($_POST['delete'])) {
class=
"badge bg-danger"
>
Hapus
</button>
</form>
</td>
<td>
<form
action=
"edit.php"
method=
"POST"
>
<input
type=
"hidden"
id=
"nikEdit"
name=
"nikEdit"
value=
"
<?php
echo
"
{
$item
[
'NIK'
]
}
"
?>
"
>
<button
type=
"submit"
name=
"delete"
class=
"badge bg-success"
>
Edit
</button>
</form>
</td>
</tr>
<?php
}
?>
</tbody>
...
...
This diff is collapsed.
Click to expand it.
penduduk.php
View file @
bfe2d099
...
...
@@ -33,6 +33,12 @@ class Penduduk
$prosesTambah
=
mysqli_query
(
$koneksi
,
$tambahData
);
}
function
updateData
(
$koneksi
)
{
$update
=
"UPDATE `data_penduduk` SET `NIK` = '
$this->nik
', `nama` = '
$this->nama
', `gender` = '
$this->gender
', `alamat` = '
$this->alamat
', `status` = '
$this->status
', `pekerjaan` = '
$this->pekerjaan
', `warga_negara` = '
$this->wargaNegara
', `tempat_lahir` = '
$this->tempatLahir
', `tanggal_lahir` = '
$this->tanggalLahir
', `gol_darah` = '
$this->golDarah
' WHERE `data_penduduk`.`NIK` = '
$this->nik
'"
;
$prosesUpdate
=
mysqli_query
(
$koneksi
,
$update
);
}
// ambil data
function
ambilData
(
$koneksi
)
{
...
...
@@ -41,6 +47,14 @@ class Penduduk
return
$prosesAmbilData
;
}
// ambil data
function
ambilDataByNIK
(
$koneksi
,
$nik
)
{
$dataPenduduk
=
"SELECT * FROM data_penduduk WHERE `NIK`=
$nik
"
;
$prosesAmbilData
=
mysqli_query
(
$koneksi
,
$dataPenduduk
);
return
$prosesAmbilData
;
}
// hapus data
function
hapusData
(
$koneksi
,
$nik
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help