-
Notifications
You must be signed in to change notification settings - Fork 0
/
processsupplier.php
75 lines (60 loc) · 1.65 KB
/
processsupplier.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
<?php
include_once 'koneksi.php';
$do = $_GET['do'];
if($do == 'add')
{
$namasupplier = $_POST['namasupplier'];
$kontaksupplier = $_POST['kontaksupplier'];
$alamat = $_POST['alamat'];
$query = mysqli_query($koneksi, "INSERT INTO m_supplier (supplier_name,supplier_contact,supplier_address) VALUES ('$namasupplier','$kontaksupplier','$alamat')") or die(mysqli_error($koneksi));
if($query)
{
setcookie("sukses", "DATA BERHASIL DITAMBAHKAN!", time() + 5, "/");
load();
}
else
{
echo 'GAGAL';
}
}
elseif ($do == 'wantedit') {
$id = $_GET['id'];
$supplier = mysqli_query($koneksi,"SELECT * FROM m_supplier WHERE supplier_id='$id'");
$data = mysqli_fetch_array($supplier);
echo json_encode($data);
}
elseif ($do == 'edit') {
$id = $_GET['id'];
$namasupplier = $_POST['namasupplier'];
$kontaksupplier = $_POST['kontaksupplier'];
$alamat = $_POST['alamat'];
$query = mysqli_query($koneksi, "UPDATE m_supplier SET supplier_name='$namasupplier', supplier_contact='$kontaksupplier', supplier_address='$alamat' WHERE supplier_id='$id'") or die(mysqli_error($koneksi));
if($query)
{
setcookie("sukses", "DATA BERHASIL DI EDIT!", time() + 10, "/");
load();
}
else
{
echo 'GAGAL';
}
}
elseif ($do = 'delete') {
$id = $_GET['id'];
$query = mysqli_query($koneksi, "DELETE FROM m_supplier WHERE supplier_id='$id'") or die(mysqli_error($koneksi));
if($query)
{
setcookie("sukses", "DATA BERHASIL DIHAPUS!", time() + 10, "/");
load();
}
else
{
echo 'GAGAL';
}
}
function load(){
echo '<script type="text/javascript">
window.location.replace("supplier.php");
</script>';
}
?>