-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.php
More file actions
132 lines (111 loc) · 4 KB
/
header.php
File metadata and controls
132 lines (111 loc) · 4 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
<?php
require_once "config.php";
session_start();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap and FontAwesome CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Custom CSS file -->
<link rel="stylesheet" href="css/custom.css">
<title>Simple Click</title>
</head>
<body>
<!-- Navbars -->
<nav class="navbar navbar-expand-lg navbar-light bg-light mx-2">
<a class="navbar-brand" href="#">Simple Click</a>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<?php
// Displays either login or logout on the right, depending on user's
// current status (session).
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
echo '<a class="nav-link" href="logout.php">Logout</a>';
}
else {
echo '<button type="button" class="btn nav-link" data-toggle="modal" data-target="#loginModal">Login</button>';
}
$h_seller_id = $_SESSION['userID'];
$h_sql = "select seller_id,SUM(current_price)from item where seller_id='$h_seller_id' and status= '1'";
$h_exist = "select * from income where seller_id='$h_seller_id'";
$h_result = $link->query($h_sql);
$h_exist_result = $link->query($h_exist);
$h_row = $h_result->fetch_assoc();
$revenue = $h_row["SUM(current_price)"];
if (empty($revenue)) {
$revenue = "0";
}
if ($h_exist_result->num_rows > 0) {
$income = "insert into income (seller_id, revenue) values('$h_seller_id','$revenue')";
}
mysqli_query($link,$income);
?>
</li>
</ul>
</nav>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<ul class="navbar-nav align-middle">
<li class="nav-item mx-1">
<a class="nav-link" href="browse.php">Browse</a>
</li>
<?php
if (isset($_SESSION['account_type']) && $_SESSION['account_type'] == 'buyer') {
echo('
<li class="nav-item mx-1">
<a class="nav-link" href="mybids.php">My Bids</a>
</li>
<li class="nav-item mx-1">
<a class="nav-link" href="recommendations.php">Recommended</a>
</li>
<li class="nav-item mx-1">
<a class="nav-link" href="watchlist.php">Watch List</a>
</li>
<li class="nav-item mx-1">
<a class="nav-link" href="profile.php">My Profile</a>
</li>');
}
if (isset($_SESSION['account_type']) && $_SESSION['account_type'] == 'seller') {
echo('
<li class="nav-item mx-1">
<a class="nav-link" href="mylistings.php">My Listings</a>
</li>
<li class="nav-item ml-3">
<a class="nav-link btn border-light" href="creat_auction.php">+ Create auction</a>
</li>
<li class="nav-item ml-3">
<a class="nav-link btn border-light" href="profile.php">Total revenue: £' . $revenue . '</a>
</li>');
}
?>
</ul>
</nav>
<!-- Login modal -->
<div class="modal fade" id="loginModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Login</h4>
</div>
<!-- Modal body -->
<div class="modal-body">
<form method="POST" action="login_result.php">
<div class="form-group">
<label for="email">Email</label>
<input name="email" type="text" class="form-control" id="email" placeholder="Email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input name="password" type="password" class="form-control" id="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary form-control">Sign in</button>
</form>
<div class="text-center">or <a href="register.php">create an account</a></div>
</div>
</div>
</div>
</div> <!-- End modal -->