Repository navigation
Expand file tree
/
Copy pathviewBookmarks.php
More file actions
184 lines (167 loc) · 5.29 KB
/
Copy pathviewBookmarks.php
File metadata and controls
184 lines (167 loc) · 5.29 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
session_start();
$cookie_name = 'name';
if(isset($_COOKIE[$cookie_name])) {
$name = $_COOKIE[$cookie_name];
}
else{
header("Location: login_page/login.php");
}
if(isset($_COOKIE['role'])) {
$role = $_COOKIE['role'];
}
$rows = array();
$servername = "localhost";
$username = "root";
$password = "test";
$db_name = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $db_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
else {
$sql = "Select p.* from myDB.Bookmarks b, myDB.product p where b.pid = p.id and b.username = '$name';";
if ($result=mysqli_query($conn,$sql))
{
if(mysqli_num_rows($result) > 0)
{
while($r = mysqli_fetch_assoc($result))
{
$rows[] = $r;
}
}
else{
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Your Bookmarks</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="css/contact.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" src="js/bookmark.js"></script>
<style type="text/css">
a{
color: #EEEDEB;
}
#bookmark{
color: black;
}
#bookmark>thead>tr{
background-color: #999896;
}
#bookmark>tbody>tr{
border-radius: 4px;
background-color: #EEEDEB;
}
#bookmark>tbody>tr>td>a{
color: black;
}
</style>
</head>
<body style="background-color: #990000; color: #EEEDEB">
<nav>
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<a class="navbar-brand" href="home.php">HoosierBazaar</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="about.php">About Us</a> </li>
<li><a href="contact.php">Contact Us<span class="sr-only">(current)</span></a> </li>
<?php
if(isset($name))
{
?>
<li><a href="viewBookmarks.php">My Bookmarks</a></li>
<?php
if(isset($role) && (strcmp($role, 'Admin') == 0) )
{ ?>
<li><a href="feedback.php">View Feedback</a></li>
<?php
}
}
?>
</ul>
<ul class="nav navbar-nav navbar-right hidden-sm">
<?php
if(isset($name))
{
?>
<li><a href="login_page/logout.php?redirect_url=<?php echo $_SERVER['PHP_SELF']; ?>">Logout</a></li>
<li><a href="#">Welcome <?php echo $name; ?>!</a></li>
<?php
}
else {
?>
<li><a href="login_page/login.html">Login / Register</a></li>
<?php
}
?>
</ul>
</div>
</div>
</nav>
<div class="container">
<table id="bookmark" class="table table-bordered">
<?php
if( sizeof($rows) > 0)
{
?>
<caption>Your Bookmarks</caption>
<thead>
<tr>
<th>Product</th>
<th>Image</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
foreach($rows as $row){
?>
<tr>
<td>
<a href="<?php echo $row['link']; ?>" target="_blank"><?php echo $row['name']; ?></a>
</td>
<td>
<img style="height: 200px; width: 200px;" src="images/<?php echo $row['img_loc']; ?>">
</td>
<td>
<button data-custom-value="<?php echo $row['id']; ?>" data-name-value="<?php if(isset($_COOKIE[$cookie_name])) {
echo $name;
}?>" type="button" class="btn btn-danger delete-button">Delete</button>
</td>
</tr>
<?php
}
?> </tbody> <?php
}
else
{ ?>
<caption>You do not have any bookmarks!!</caption>
<?php
}
?>
</table>
</div>
<br>
<footer class="text-center my-footer">
<div class="container">
<div class="row">
<div class="col-xs-12">
<p>Copyright © HoosierBazaar.com All rights reserved.</p>
</div>
</div>
</div>
</footer>
</body>
</html>