-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderSend.php
55 lines (40 loc) · 1.45 KB
/
orderSend.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
<?php
include_once("includes/session.php");
include_once("includes/checkUser.php");
include_once("includes/databaseConnect.php");
$notify = "Košik je prázdny.";
$message = $_POST['message'];
$order_id = date('YmdHs');
$SQL = "SELECT * FROM `users`
where id= " . GetSession("UserId");
$results = $connection->query($SQL);
if ($results) {
$user = $results->fetch_object();
}
$basket_id = $_COOKIE['shopping_cart_id'];
$SQL = "SELECT * FROM `basket`
inner join products on basket.product_code = products.product_code
where basket.basket_id='$basket_id' ";
$results = $connection->query($SQL);
if ($results) {
while ($obj = $results->fetch_object()) {
$notify = "Objednavka bola odoslaná.";
$SQL = "insert into orders (order_id,message,email,user_name,user_address,product_code,product_name,price, quantity )
values ('$order_id','$message','$user->email','$user->name','$user->address','$obj->product_code', '$obj->product_name', $obj->price, $obj->quantity )";
$connection->query($SQL);
}
$SQL = "delete from `basket` where basket.basket_id='$basket_id'";
$results = $connection->query($SQL);
}
include_once("pageHeader.php");
?>
<div class="container">
<div class="well well-sm">
<p><?php echo $notify ?></p>
<a href="products.php" class="btn btn-success">Pokračovať</a>
</div>
</div>
<?php
include_once("pageFooter.php");
include_once("includes/databaseClose.php");
?>