-
Notifications
You must be signed in to change notification settings - Fork 2
/
process.php
73 lines (57 loc) · 2.01 KB
/
process.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
<?php
session_start();
require_once "./functions/database_functions.php";
$title = "Purchase Process";
require "./template/header.php";
$conn = db_connect();
$firstname = trim($_POST['firstname']);
$firstname = mysqli_real_escape_string($conn, $firstname);
$lastname = trim($_POST['lastname']);
$lastname = mysqli_real_escape_string($conn, $lastname);
$address = trim(trim($_POST['address']));
$address = mysqli_real_escape_string($conn, $address);
$city = trim($_POST['city']);
$city = mysqli_real_escape_string($conn, $city);
$zipcode = trim($_POST['zipcode']);
$zipcode = mysqli_real_escape_string($conn, $zipcode);
// find customer
$customer = getCustomerIdbyEmail($_SESSION['email']);
$id=$customer['id'];
$query="UPDATE customers set
firstname='$firstname', lastname='$lastname' , address='$address', city='$city', zipcode='$zipcode' where id='$id'
";
mysqli_query($conn, $query);
$date = date("Y-m-d H:i:s");
// insertIntoOrder($conn, $customer['id'], $_SESSION['total_price'],$date);
insertIntoCart($conn, $customer['id'],$date);
// take orderid from order to insert order items
// $orderid = getOrderId($conn, $customer['id']);
$Cartid = getCartId($conn, $customer['id']);
foreach($_SESSION['cart'] as $serial => $qty)
{
$medprice = getmedprice($serial);
$query = "INSERT INTO cartitems(cartid,productid,quantity) VALUES ('$Cartid', '$serial', '$qty')";
$result = mysqli_query($conn, $query);
if(!$result)
{
echo "Insert value false!" . mysqli_error($conn2);
exit;
}
}
unset($_SESSION['total_price']);
unset($_SESSION['cart']);
unset($_SESSION['total_items']);
?>
<p class="lead text-success" id="p">Your order has been processed sucessfully..</p>
<script>
window.setTimeout(function()
{
window.location.href = "https://localhost/med/index.php";
}, 3000);
</script>
<?php
if(isset($conn)){
mysqli_close($conn);
}
require_once "./template/footer.php";
?>