-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofileView.php
More file actions
168 lines (158 loc) · 5.39 KB
/
profileView.php
File metadata and controls
168 lines (158 loc) · 5.39 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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
require 'db.php';
$category=$_SESSION['Category'];
$id=$_SESSION['id'];
if(!isset($_SESSION['logged_in']) OR $_SESSION['logged_in'] != 1)
{
$_SESSION['message'] = "You have to Login to view this page!";
header("Location: Login/error.php");
}
$sql = "SELECT * FROM review";
$result = mysqli_query($conn, $sql);
$totalRating = 0;
// Check if there are any rows returned
if (mysqli_num_rows($result) > 0) {
// Loop through each row
$count = 0;
while ($row = mysqli_fetch_assoc($result)) {
// Add the rating of the current row to the total rating
$totalRating += $row['rating'];
$count += 1;
}
} else {
$count = 1;
$totalRating = 0;
}
$totalRating = $totalRating / $count;
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Profile: <?php echo $_SESSION['Username']; ?></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="bootstrap\css\bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/custom.css">
<body style="background: linear-gradient(135deg, #ffffff, #f2f2f2);">
<style>
/* Gradient background */
body {
background: linear-gradient(120deg, #ff85a2, #ffc3a0);
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
.container {
max-width: 800px;
margin: auto;
padding: 20px;
text-align: center;
}
.profile-box {
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.profile-picture {
width: 150px;
height: 150px;
border-radius: 50%;
margin: auto;
display: block;
}
.profile-name {
margin-top: 10px;
color: #333;
}
.profile-info p {
margin: 5px 0;
color: #666;
}
.btn-group {
margin-top: 20px;
}
.btn-group .btn {
margin: 10px;
padding: 15px 40px;
font-size: 18px;
}
/* Style for file input */
.custom-file-input {
color: transparent;
}
.custom-file-input::-webkit-file-upload-button {
visibility: hidden;
}
.custom-file-input::before {
content: 'Select Profile Picture';
color: #fff;
background-color: #dc3545;
border-radius: 5px;
padding: 8px 20px;
display: inline-block;
cursor: pointer;
}
.custom-file-input:hover::before {
background-color: #c82333;
}
.custom-file-input:active::before {
background-color: #bd2130;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="bootstrap\js\bootstrap.min.js"></script>
<script>
// Function to display selected profile picture
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#profilePicture').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$(document).ready(function(){
// Trigger file input on click
$('.custom-file-input').click(function(){
$(this).next().trigger('click');
});
// Display selected profile picture
$('#customFile').change(function(){
readURL(this);
});
});
</script>
</head>
<body>
<?php require 'menu.php'; ?>
<div class="container">
<div class="profile-box">
<form action="uploadProfilePic.php" method="post" enctype="multipart/form-data">
<input type="file" name="profile_pic" class="custom-file-input" id="customFile">
<label class="profile-picture-label" for="customFile">
<img id="profilePicture" src="images/profileImages/profile0.png?<?php echo mt_rand(); ?>" class="profile-picture" alt="Profile Picture">
</label>
<h2 class="profile-name"><?php echo $_SESSION['Name']; ?></h2>
<h4 class="profile-username"><?php echo $_SESSION['Username']; ?></h4>
<div class="profile-info">
<p><strong>Email ID:</strong> <?php echo $_SESSION['Email']; ?></p>
<p><strong>ADDRESS:</strong> <?php echo $_SESSION['Addr']; ?></p>
<p><strong>Mobile No:</strong> <?php echo $_SESSION['Mobile']; ?></p>
<p><strong>Rating:</strong> <?php echo $totalRating; ?></p>
</div>
<div class="btn-group">
<a href="changePassPage.php" class="btn btn-danger">Change Password</a>
<a href="uploadProduct.php" class="btn btn-danger">Upload Product</a>
<a href="profileEditPage.php" class="btn btn-danger">Edit Profile</a>
</div>
<a href="Login/logout.php" class="btn btn-danger">LOG OUT</a>
</form>
</div>
</div>
</body>
</html>