-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer_pembayaran_act.php
37 lines (30 loc) · 1017 Bytes
/
customer_pembayaran_act.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
<?php
include 'koneksi.php';
$alert = 'gagal';
$id = $_POST['id'];
$rand = rand();
$allowed = array('gif','png','jpg','jpeg');
$filename = $_FILES['bukti']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (in_array($ext, $allowed)) {
$lama = mysqli_query($koneksi, "select * from check_in where id_transaksi='$id'");
$l = mysqli_fetch_assoc($lama);
$foto_lama = $l['invoice_bukti'];
$foto_baru = sprintf('gambar/bukti_pembayaran/%s.%s', $rand, $ext);
move_uploaded_file($_FILES['bukti']['tmp_name'], $foto_baru);
$query = "
update check_in
set invoice_bukti='$foto_baru', status='non-valid', invoice_status='1'
where id_transaksi='$id'";
$update = mysqli_query($koneksi, $query);
$error = mysqli_error($koneksi);
// jika gagal update
if ($error) {
unlink($foto_baru);
} else {
$alert = 'upload';
// hapus gambar lama
unlink($foto_lama);
}
}
header("location:customer_pesanan.php?alert=$alert");