-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinsertTukang.php
More file actions
47 lines (39 loc) · 1.49 KB
/
insertTukang.php
File metadata and controls
47 lines (39 loc) · 1.49 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
<?php
include_once('koneksi.php');
if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['address']) && !empty($_POST['handphone']) && !empty($_POST['password']) && !empty($_POST['nik'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$address = $_POST['address'];
$handphone = $_POST['handphone'];
$nik = $_POST['nik'];
$password = md5($_POST['password']);
if (empty($_FILES['ktp']) && empty($_FILES['selfie_ktp'])) {
set_response(false, "Foto harus diisi");
} else {
$ktp = $_FILES['ktp']['name'];
$file1 = $_FILES['ktp']['tmp_name'];
$dir1 = "ktp/";
move_uploaded_file($file1, $dir1 . $ktp);
$selfie_ktp = $_FILES['selfie_ktp']['name'];
$file2 = $_FILES['selfie_ktp']['tmp_name'];
$dir2 = "selfie_ktp/";
move_uploaded_file($file2, $dir2 . $selfie_ktp);
$query = "INSERT INTO tukang(name, email, address, handphone, ktp, selfie_ktp, password, nik) VALUES ('$name', '$email', '$address','$handphone', '$ktp', '$selfie_ktp', '$password', '$nik')";
$insert = pg_query($connect, $query);
if ($insert) {
set_response(true, "Success insert tukang");
} else {
set_response(false, "Failed insert tukang");
}
}
} else {
set_response(false, "Harus diisi");
}
function set_response($isSuccess, $message)
{
$result = array(
'isSuccess' => $isSuccess,
'message' => $message
);
echo json_encode($result);
}