-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
134 lines (131 loc) · 4.48 KB
/
profile.php
File metadata and controls
134 lines (131 loc) · 4.48 KB
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
<?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>LuLa Shop</title>
<?php include 'menu.php'; ?>
<?php
//TODO: create account for this app
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "lulashop";
// Connect to the database
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
die();
}
?>
</head>
<body>
<p> This is where you check on orders that you have purchased, update your addresses, and manage which sellers you follow.</p>
<div class="w3-container">
<h2>My Addresses</h2>
<form method="post" action="address.php">
<button class="w3-btn w3-green w3-large" type="submit" value="Add Address">Add Address</button>
<input hidden name="mode" value="add">
</form>
<br>
<form method="post" action="address.php">
<button class="w3-btn w3-green w3-large" type="submit" value="Add Address">Update Address</button>
<input hidden name="mode" value="kevinWTF">
</form>
<br>
<form method="post" action="address.php">
<button class="w3-btn w3-green w3-large" type="submit" value="Add Address">Remove Address</button>
<input hidden name="mode" value="remove">
</form>
</div>
<div class="w3-container">
<h2>Manage Who I Follow</h2>
<form method="post" action="follow.php">
<button class="w3-btn w3-green w3-large" type="submit" value="Add Address">Manage</button>
</form>
</div>
<div class="w3-container">
<p> The following orders have not shipped yet: <p>
<table class="w3-table w3-striped">
<tr>
<th>Invoice</th>
<th>Date</th>
</tr>
<?php
if (isset($_SESSION["userID"])) {
$userType = $_SESSION["userType"];
$user = $_SESSION["userID"];
$sql = "SELECT `invoiceNumber`, `_date` FROM `invoice` WHERE `shipped`=0 AND ";
if ($userType == "user"){
$sql .="userID='$user'";
} else {
$sql .="memberID='$user'";
}
$pdo = $conn->query($sql);
while ($result = $pdo->fetch()) {
echo "<tr><td><form method=\"post\" action=\"showinvoice.php\" target=\"invoice\">";
echo "<input type=\"submit\" style=\"font-size:24px\" onclick=\"showInvoice()\" value=\"".$result["invoiceNumber"]."\">";
echo "<input type='number' hidden name='invoiceNumber' value='".$result["invoiceNumber"]."'></form></td>";
echo "<td>".$result["_date"]."</td></tr>";
}
}
?>
</table>
</div>
<div class="w3-container">
<p> The following orders have shipped: <p>
<table class="w3-table w3-striped">
<tr>
<th>Invoice</th>
<th>Date</th>
<th>Tracking Number</th>
</tr>
<?php
if (isset($_SESSION["userID"])) {
$userType = $_SESSION["userType"];
$user = $_SESSION["userID"];
$sql = "SELECT `invoiceNumber`,`_date`,`tracking` FROM `invoice` WHERE `shipped`=1 AND ";
if ($userType == "user"){
$sql .="userID='$user'";
} else {
$sql .="memberID='$user'";
}
$pdo = $conn->query($sql);
while ($result = $pdo->fetch()) {
echo "<tr><td><form method=\"post\" action=\"showinvoice.php\" target=\"invoice\">";
echo "<input type=\"submit\" style=\"font-size:24px\" onclick=\"showInvoice()\" value=\"".$result["invoiceNumber"]."\">";
echo "<input type='number' hidden name='invoiceNumber' value='".$result["invoiceNumber"]."'></form></td>";
echo "<td>".$result["_date"]."</td>";
echo "<td><a href='".$result["tracking"]."'>".$result["tracking"]."</td></tr>";
}
}
?>
</table>
</div>
<div id="invoice" class="w3-modal">
<div class="w3-modal-content">
<div class="w3-container">
<span onclick="document.getElementById('invoice').style.display='none'" class="w3-closebtn">×</span>
<iframe name="invoice" height="400px" width="100%" src="showinvoice.php">invoice</iframe>
</div>
</div>
</div>
<script>
function showInvoice(){
document.getElementById('invoice').style.display='block';
}
</script>
</body>
<!-- close DB connection -->
<?php $conn = null;?>
<footer>
<?php include 'foot.php'; ?>
</footer>
</html>