-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
200 lines (169 loc) · 7.12 KB
/
profile.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php session_start(); ?>
<?php
include("connection.php");
$loggedUsername = $_SESSION['username'];
if(isset($_POST['edit']))
{
$e_mail = $_POST['e_mail'];
$password = $_POST['password'];
$sql = "UPDATE user SET e_mail = '$e_mail', password = '$password' ";
$result = mysqli_query($con, $sql);
}
if(isset($_POST['rateReview']))
{
$rate = $_POST['rate'];
$review = $_POST['review'];
$sql = "INSERT INTO reviews (username, rating, review) values ('$loggedUsername', '$rate', '$review')";
$result = mysqli_query($con, $sql);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile</title>
<link rel="stylesheet" href="css/profile-css.css" type="text/css">
</head>
<body>
<div class="row">
<div class="column side-bar">
<h1 class="side-head">Food Finder</h1>
<p class="side-tag">delivering the best food at your doorstep :)</p>
</br></br>
<h1>
<span class="text_1">Hungry??</span>
<span class="text_2">Order food now!!</span>
</h1>
</br></br>
<a href="home.php" class="button button-accent button-small"><strong>Order Now</strong></a>
</br></br>
<a href="#review" class="button button-accent button-small"><strong>Rate & Review</strong></a> </br>
</div>
<div class="column main-page">
<!-- <header> -->
<nav>
<ul>
<li><a href="logout.php" class="nav-li">LOGOUT</a></li>
<?php
$query = "SELECT item FROM orders WHERE id = 1";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
if(isset($row['item'])){
?>
<li><a href="cart.php" class="nav-li">CART</a></li>
<?php
}
else{
?>
<li><a href="empty_cart.php" class="nav-li">CART</a></li>
<?php } ?>
<li><a href="home.php" class="nav-li">HOME</a></li>
</ul>
</nav>
<!--</header>-->
<?php
$sql = ("SELECT * FROM user WHERE username = '$loggedUsername' ");
$result = mysqli_query($con, $sql);
$num = mysqli_num_rows($result);
for($i = 1; $i <= $num; $i++)
{
$row = mysqli_fetch_array($result);
?>
<h1 class="main-head">Profile Page</h1>
<table class="profile-main">
<tr>
<td class="profile-td">Username</td>
<td class="profile-td"><?php echo $row['username']; ?></td>
</tr>
<tr>
<td class="profile-td">E-mail</td>
<td class="profile-td"><?php echo $row['e_mail']; ?></td>
</tr>
<tr>
<td class="profile-td">Password</td>
<td class="profile-td"><?php echo $row['password']; } ?></td>
</tr>
</table>
</br></br>
<a href="#edit" class="button button-accent button-small"><strong>Edit Details</strong></a>
<a href="#showReview" class="button button-accent button-small"><strong>Show Previous Reviews</strong></a>
</div>
</div>
<div id="edit" class="overlay">
<div class="popup">
<h2>Enter New Details</h2>
<a class="close" href="#">×</a>
<div class="content">
<form action="" method="POST">
<table>
<tr class="popup-tr">
<td class="popup-td">New E-mail</td>
<td class="popup-td"><input type="text" name="e_mail" id="input"></td>
</tr>
<tr class="popup-tr">
<td class="popup-td">New password</td>
<td class="popup-td"><input type="password" name="password" id="input"></td>
</tr>
<tr class="popup-tr">
<td></td>
<td class="popup-td" style="float: right;"><input type="submit" name="edit" value="EDIT" class="button button-accent button-small"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div id="review" class="overlay">
<div class="popup">
<h2>Rate and Review</h2>
<a class="close" href="#">×</a>
<div class="content">
<form action="" method="POST">
<table>
<tr class="popup-tr">
<td class="popup-td">Rate</td>
<td class="popup-td"><input type="number" name="rate" id="inputRate"></td>
</tr>
<tr class="popup-tr">
<td class="popup-td">Review</td>
<td class="popup-td"><input type="text" name="review" id="inputReview" style="height: 6em"></td>
</tr>
<tr class="popup-tr">
<td></td>
<td class="popup-td" style="float: right;"><input type="submit" name="rateReview" value="SUBMIT" class="button button-accent button-small"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div id="showReview" class="overlay">
<div class="popup">
<h2>Previous Ratings and Reviews</h2>
<a class="close" href="#">×</a>
<div class="content">
<table>
<tr class="popup-tr" style="margin-left: 3.5em; display: block">
<td class="popup-td" style="font-size: 1.3em">Rate</td>
<td class="popup-td" style="font-size: 1.3em">Review</td>
</tr>
<?php
$q = ("SELECT rating, review FROM reviews WHERE username = '$loggedUsername' ");
$res = mysqli_query($con, $q);
$num = mysqli_num_rows($res);
for($i = 1; $i <= $num; $i++)
{
$row = mysqli_fetch_array($res);
?>
<tr class="popup-tr">
<td class="popup-td"><?php echo $row['rating']; ?></td>
<td class="popup-td"><?php echo $row['review']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</body>
</html>