-
Notifications
You must be signed in to change notification settings - Fork 0
/
beforeCheckout.php
executable file
·145 lines (102 loc) · 4.28 KB
/
beforeCheckout.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
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Quikshop Mobile</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<meta content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
</head>
<body>
<div data-role="page" data-theme="b">
<div data-role="header" data-theme="b">
<h1><img src="logo.png" width="126" height="26" align="middle" /></h1>
<a href="help.html" data-icon="info" class="ui-btn-right" position:absolute top:50% data-transition="slide">Help</a>
<a href="scanner.html" class="ui-btn-left" data-icon="arrow-l" data-iconpos="left" data-transition="slide" data-direction="reverse">Back</a>
</div>
<script>
if (localStorage.getItem("userId") === "signOut") {
alert("you are not logged in");
window.location.assign("http://abelalvarez.info/quikshop/www/")
}
</script>
<div data-role="content">
<div id="landmark-1" data-landmark-id="1">
<?php
// Connect to the database NOTE: Hostgator may need another connection route than 'localhost'
//$mysqli = new mysqli("quikshop.co","cx300_cen3031","[cEn..3031!]","cx300_quikshop");
$mysqli = new mysqli("ec2-54-186-201-14.us-west-2.compute.amazonaws.com","quikshop","quikshop2014uf","quikshop");
// Allow for errors
error_reporting(E_ALL);
ini_set('display_errors', '1');
$userID = 34;//$_SESSION['userId'];
$cartID = 1;//$_SESSION['currCartId'];
$sql = "SELECT itemID, quantity From Cart where cartID = $cartID";
// Call the database, save the result in the variable RESULT
$result = $mysqli->query($sql) or die( $mysqli->error );
// Extract the row data of the result. Save as ROQ
$sum = 0;
$quantity = 0;
//while loop will look in the customer's cart all the items
while($row = mysqli_fetch_row($result)){
//save the quantity of the current item
$itemid = $row[0];
$quantity = $row[1];
//look for the items price using
$sqlr = "SELECT price From Items where itemID = $itemid ";
$resultr = $mysqli->query($sqlr) or die( $mysqli->error );
$rowr = mysqli_fetch_row($resultr);
$sum = $sum + $quantity*$rowr[0];
}
?>
<center>
<font size="18">Amount Due
<?php
print("$$sum");
?>
</font>
</center>
<?php
$cardID = 2;
//print("I am here before it does the while loop");
$sqlcard = "SELECT type, cardNumber From CreditCard where cardID = $cardID ";
//print ("I am here after the query");
$resultcard = $mysqli->query($sqlcard) or die( $mysqli->error );
$x = 0;
while($rowcard = mysqli_fetch_row($resultcard)){
$arrayNumber[] = $rowcard[0];
$arrayType[] = $rowcard[1];
}
print_r($arrayNumber);
print_r($arrayType);
$_SESSION['userID'] = $userID;
$_SESSION['cartID'] = $cartID;
$_SESSION['total'] = $sum;
$_SESSION['number'] = $arrayNumber;
$_SESSION['type'] = $arrayType;
?>
<div data-role="content">
<div id="landmark-1" data-landmark-id="1">
<form id ="Continue" method="post" action="checkout_html.php">
<input type="submit" name="submit" value="Continue">
</form>
<br />
<form id ="Cancel" method="post" action="scanner.html">
<input type="submit" name="cancel" value="Cancel">
</form>
<div data-role="fieldcontain" class="ui-hide-label">
<div style="text-align:center">
</div>
</div>
<div data-role="footer" data-position="fixed" data-theme="b" data--tap-toggle="false">
<h1>© Quikshop 2014</h1>
</div>
</div>
<?php
$mysqli->close();
?>
</body>
</html>