-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinput.php
executable file
·60 lines (59 loc) · 1.76 KB
/
input.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
<?php
session_start();
error_reporting(0);
include "include/lib.php";
$input=$_GET[input];
$sid = session_id();
$inputform=$_GET[inputform];
if($input=='add'){
$sql = mysql_query("SELECT id_product FROM keranjang WHERE id_product='$_GET[id]' AND id_session='$sid'");
$num = mysql_num_rows($sql);
if ($num==0){
mysql_query("INSERT INTO keranjang(id_product,
id_session,
tgl_keranjang,
qty)
VALUES ('$_GET[id]',
'$sid',
'$tgl_sekarang',
'1')") or die (mysql_error());
}
else {
mysql_query("UPDATE keranjang SET qty = qty + 1 WHERE id_session = '$sid' AND id_product='$_GET[id]'") or die (mysql_error());
}
deletecart();
header('location:index.php?v=cart');
}
elseif ($input=='delete'){
mysql_query("DELETE FROM keranjang WHERE id_keranjang='$_GET[id]'");
header('location:index.php?v=cart');
}
elseif ($input=='inputform'){
$ct_content = cart_content();
$jml = count($ct_content);
$now = date("Ymd");
for($i=0; $i<$jml; $i++){
mysql_query("INSERT INTO order_product(name,
email,
phone,
address,
id_product,
jumlah,
tanggal,
id_pemesan)
VALUES ('$_POST[name]',
'$_POST[email]',
'$_POST[telp]',
'$_POST[address]',
{$ct_content[$i]['id_product']},
{$ct_content[$i]['qty']},
'$now',
'$sid')");
}
for($i=0; $i<$jml; $i++){
mysql_query("DELETE FROM keranjang WHERE id_keranjang = {$ct_content[$i]['id_keranjang']}");
}
echo "<script>window.alert('Terima Kasih Pesanan Anda Sedang Kami Proses');
window.location=('index.php?v=terimakasih')</script>";
}
?>