-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
38 lines (31 loc) · 911 Bytes
/
delete.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
<?php
function getKey() {
return ["apikey1234", "apikey5678", "myapikey"];
}
function isValid($input) {
$apikey = $input["api_key"];
if (in_array($apikey, getKey())) {
return true;
} else {
return false;
}
}
function jsonOut($status, $message) {
$respon = ["status" => $status, "message" => $message];
header("Content-type: application/json");
echo json_encode($respon);
}
function deleteData() {
include 'conn.php';
$id = addslashes(htmlentities($_POST['id']));
$getdata = mysqli_query($conn,"SELECT * FROM produk WHERE id='$id'");
$rows = mysqli_num_rows($getdata);
$sql = "DELETE FROM produk WHERE id = '$id'";;
$koneksi = mysqli_query($conn, $sql);
}
if (isValid($_GET)) {
jsonOut("Success", "Delete Data Succes", deleteData());
} else {
jsonOut("Not Success", "Delete Data Not Success");
}
?>