-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaftercheckout.php
159 lines (139 loc) · 6.16 KB
/
aftercheckout.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
$dbhost = 'remotemysql.com:3306';
$dbuser = 'HTADFpjYkD';
$dbpass = 'wfJDJmJgdL';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbuser);
if(! $conn ) {
die('Could not connect: ' . mysqli_error());
}
session_start();
//get user info
$email = $_SESSION['email'];
$query = "SELECT id from register where email = '$email'";
$result = $conn->query($query);
$row = $result->fetch_assoc();
$id = $row['id'];
//insert order
$query = "INSERT INTO orders (register_id) VALUES ('$id')";
$conn->query($query);
$last_id = $conn->insert_id;
//insert items
if (!empty($_SESSION["cart"])) {
foreach ($_SESSION['cart'] as $key => $value) {
$item_name = $value["item_name"];
$product_price = $value["product_price"];
$item_quantity = $value["item_quantity"];
$query = "INSERT INTO orders_products (order_id, product_name, product_price, product_quantity)
VALUES ('$last_id', '$item_name','$product_price','$item_quantity')";
$conn->query($query);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Online Grocery</title>
<link rel="icon" href="trolley.png">
<link rel="stylesheet" href="aftersignup.css">
<!-- general -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="project.css">
<link rel="stylesheet" type="text/css" href="">
<link rel="icon" href="trolley.png">
</head>
<body>
<!-- Nav bar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<img src="trolley.png" class="navbar-brand" style="width: 40px;">
<a class="navbar-brand" href="#">Online Grocery Shopping</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto mx-auto">
<li class="nav-item active">
<a class="nav-link" href="home.php">Home <span class="sr-only"></span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="AllProducts.php">All Products</a>
</li>
<li class="nav-item dropdown active">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Aisles
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="meataisle.php">Meat</a>
<a id="disabled" class="dropdown-item" href="dairy.php">Dairy</a>
<a id="disabled" class="dropdown-item" href="beveragesaisle.php">Beverages</a>
<a id="disabled" class="dropdown-item" href="detergents.php">Detergents</a>
<a id="disabled" class="dropdown-item" href="snacks.php">Snacks</a>
<a id="disabled" class="dropdown-item" href="alcohol.php">Alcohol</a>
</div>
</li>
<li class="nav-item active">
<a class="nav-link disabled" href="contact.php">Contact Us</a>
</li>
</ul>
<br>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" style="background-color: #343A40;">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
<?php if(isset($_SESSION['loggedin'])){ ?>
<a class="btn btn-outline-primary ml-1" href="logout.php">Log Out</a>
<?php }else{ ?>
<a class="btn btn-outline-primary ml-1" href="signinpage.php">Sign in</a>
<?php } ?>
</form>
</div>
</nav>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="bgimg">
<!-- <div class="topmiddle">
<p><img src="trolley.png" style="width: 100px;"></p>
</div> -->
<div class="middle">
<h1>Checkout complete.</h1>
</div>
<!-- <div class="bottomleft">
<p>Some text</p>
</div> -->
</div>
<!-- footer -->
<footer class="pt-4 my-md-5 pt-md-5 border-top">
<div class="row">
<div class="col-12 col-md">
<p></p>
<small class="d-block mb-3 text-muted"></small>
</div>
<div class="col-6 col-md">
<h5>Contacts</h5>
<ul class="list-unstyled text-small">
<li><a class="text-muted" href="contact.php">Manager</a></li>
<li><a class="text-muted" href="contact.php">Supervisor</a></li>
<li><a class="text-muted" href="contact.php">Our Team</a></li>
</ul>
</div>
<div class="col-6 col-md">
<h5>Careers</h5>
<ul class="list-unstyled text-small">
<li><a class="text-muted" href="careers.php">Meat Section</a></li>
<li><a class="text-muted" href="careers.php">Delivery</a></li>
</ul>
</div>
<div class="col-6 col-md">
<h5>About</h5>
<ul class="list-unstyled text-small">
<li><a class="text-muted" href="contact.php">Team</a></li>
<li><a class="text-muted" href="https://www.google.com/maps/place/11011+Bd+Maurice-Duplessis,+Montr%C3%A9al,+QC+H1C+1V3/@45.6660703,-73.5345729,17z/data=!3m1!4b1!4m5!3m4!1s0x4cc8e1759aa6762d:0x80db5bbbc6e3d671!8m2!3d45.6660703!4d-73.5323842" target="_blank">Location</a></li>
<li><a class="text-muted" href="terms.php">Privacy</a></li>
<li><a class="text-muted" href="terms.php">Terms</a></li>
</ul>
</div>
</div>
</footer>
</body>
</html>