-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·126 lines (104 loc) · 2.29 KB
/
index.php
File metadata and controls
executable file
·126 lines (104 loc) · 2.29 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
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
<?php
/*this file for remote database
filename : index.php
path : RS/index.php
versi : 1
email : ksatrianglungupertama@gmail.com
*/
header("acces-control-allow-origin");
header("content-Type: application/json; charset=UTF-8");
$db = "localhost";
$dbUser = "root";
$dbPass = "asusa442u";
$dbName = "RS";
$con = new mysqli($db, $dbUser, $dbPass, $dbName);
if ($con -> connect_error) {
die("Connection failed : ". $con->connect_error);
}
$con->query("SET CHARACTER SET utf8");
$con->query("SET NAMES 'utf8'");
$action = $_GET["action"];
switch ($action) {
/*CREATE TABLE tbwarung (
id INT(6) AUTO_INCREMENT PRIMARY KEY,
namawarung text NOT NULL,
namapemilik text NOT NULL,
alamat text NOT NULL
);*/
Case "getAllWarung":
$q = $con->query(
"SElECT * FROM tbwarung");
$rows = array();
while($r = mysqli_fetch_assoc($q))
{
$rows[] = $r;
}
print json_encode($rows);
// echo "hello";
$con->close;
break;
Case "addUser" :
$namawarung = $_GET["namawarung"];
$namapemilik = $_GET["namapemilik"];
$alamat = $_GET["alamat"];
$q = $con->query(
"INSERT INTO tbwarung(
`namawarung`,
`namapemilik`,
`alamat`) VALUES (
'$namawarung',
'$namapemilik',
'$alamat')"
);
if($q) {
print json_decode("Data berhasil di input.");
} else {
print json_encode("Data gagal di input.");
}
$con -> close();
break;
Case "updateUser" :
$id = $_GET["id"];
$namawarung = $_GET["namawarung"];
$namapemilik = $_GET["namapemilik"];
$alamat = $_GET["alamat"];
$q = $con->query(
"UPDATE tbwarung set
`namawarung` = '$namawarung',
`namapemilik` = '$namapemilik',
`alamat` = '$alamat'
where `id`='$id'");
if ($q) {
print json_encode("berhasil Update.");
} else{
json_encode("Gagal Update.");
}
$con->close();
break;
Case "deleteUser":
$id = $_GET["id"];
$q = $con->query(
"DELETE FROM users
where
`id`='$id");
if($q){
print json_encode("Terhapus");
} else {
print json_encode("Gagal menghapus");
}
$con->close();
break;
Case "getAllLokasi":
$q = $con->query(
"SElECT * FROM tblokasi");
$rows = array();
while($r = mysqli_fetch_assoc($q))
{
$rows[] = $r;
}
print json_encode($rows);
// echo "hello";
$con->close;
break;
}
?>