Repository navigation
Expand file tree
/
Copy pathprofile.php
More file actions
240 lines (220 loc) · 9.32 KB
/
Copy pathprofile.php
File metadata and controls
240 lines (220 loc) · 9.32 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
require_once 'includes/session_config.php';
include 'conn.php';
// Check for remember_me cookie to restore session if needed
if (!isset($_SESSION['logged_in']) && isset($_COOKIE['remember_me']) && $_COOKIE['remember_me'] === 'true') {
if (isset($_COOKIE['user_id']) && isset($_COOKIE['user_type'])) {
// Verify the user from database
$user_id = $_COOKIE['user_id'];
$sql = "SELECT * FROM users WHERE user_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
// Restore session
$_SESSION['user_id'] = $user['user_id'];
$_SESSION['user_name'] = $user['name'];
$_SESSION['user_type'] = $user['user_type'];
$_SESSION['email'] = $user['email'];
$_SESSION['logged_in'] = true;
}
}
}
// Check session
if (!isset($_SESSION['user_id'])) {
header("Location: signin.php");
exit();
}
// Refresh the cookies only - REMOVED the ini_set calls that were causing errors
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
// Refresh the cookies for 1 day
$cookie_expiry = time() + (24 * 60 * 60); // 1 day
setcookie('user_id', $_SESSION['user_id'], $cookie_expiry, '/');
setcookie('user_type', $_SESSION['user_type'], $cookie_expiry, '/');
setcookie('remember_me', 'true', $cookie_expiry, '/');
}
// Fetch user profile data
$user_id = $_SESSION['user_id'];
$sql = "SELECT u.*, p.*
FROM users u
LEFT JOIN profiles p ON u.user_id = p.user_id
WHERE u.user_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$user_data = $stmt->get_result()->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Freelancer Profile</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
body {
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
min-height: 100vh;
}
.glass-effect {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
nav.glass-effect {
background: rgba(30, 60, 114, 0.95);
}
.skill-tag {
background: rgba(79, 70, 229, 0.1);
color: #4F46E5;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.875rem;
}
</style>
</head>
<body>
<!-- Navigation -->
<nav class="glass-effect text-white py-4 sticky top-0 z-50">
<div class="container mx-auto px-6 flex justify-between items-center">
<div class="flex flex-col">
<a href="index.html" class="text-2xl font-bold tracking-wider hover:text-indigo-200 transition duration-300">
BidProHub
</a>
<p class="text-sm text-indigo-200">Where Ambitions meet Opportunities</p>
</div>
<div class="flex items-center space-x-6">
<a href="<?php echo $_SESSION['user_type'] === 'client' ? 'home_client.php' : 'home_user.php'; ?>" class="flex items-center text-indigo-200 hover:text-white transition duration-300">
<i class="fas fa-home mr-2"></i>
Back to Home
</a>
</div>
</div>
</nav>
<!-- Profile Section -->
<div class="container mx-auto px-6 py-8">
<div class="glass-effect rounded-lg p-8 mb-8">
<div class="flex justify-between mb-6">
<h2 class="text-2xl font-semibold text-gray-800">Profile Details</h2>
<a href="edit_profile.php" class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition duration-300 flex items-center">
<i class="fas fa-edit mr-2"></i>
Edit Profile
</a>
</div>
<div class="flex flex-col md:flex-row">
<!-- Profile Image and Basic Info -->
<!-- Update profile section with dynamic data -->
<div class="md:w-1/3 mb-6 md:mb-0">
<img src="<?php echo $user_data['profile_image'] ?? 'https://ui-avatars.com/api/?name='.urlencode($user_data['name']); ?>"
alt="<?php echo htmlspecialchars($user_data['name']); ?>"
class="rounded-lg w-48 h-48 mx-auto md:mx-0">
<div class="mt-4 text-center md:text-left">
<h1 class="text-2xl font-bold text-gray-800"><?php echo htmlspecialchars($user_data['name']); ?></h1>
<p class="text-gray-600"><?php echo htmlspecialchars($user_data['job_title'] ?? 'Professional'); ?></p>
<p class="text-gray-600 mt-2">
<i class="fas fa-map-marker-alt mr-2"></i>
<?php echo htmlspecialchars($user_data['city'] ?? ''); ?>, <?php echo htmlspecialchars($user_data['country'] ?? ''); ?>
</p>
</div>
</div>
<!-- Contact and Skills -->
<div class="md:w-2/3 md:pl-8">
<div class="mb-6">
<h2 class="text-xl font-semibold text-gray-800 mb-3">Contact Information</h2>
<p class="text-gray-600"><i class="fas fa-envelope mr-2"></i><?php echo htmlspecialchars($user_data['email']); ?></p>
<p class="text-gray-600"><i class="fas fa-phone mr-2"></i><?php echo htmlspecialchars($user_data['phone'] ?? 'Not provided'); ?></p>
</div>
<div class="mb-6">
<h2 class="text-xl font-semibold text-gray-800 mb-3">Skills</h2>
<div class="flex flex-wrap gap-2">
<?php
if (!empty($user_data['skills'])) {
$skills = explode(',', $user_data['skills']);
foreach ($skills as $skill) {
echo '<span class="skill-tag">' . htmlspecialchars($skill) . '</span>';
}
}
?>
</div>
</div>
<div>
<h2 class="text-xl font-semibold text-gray-800 mb-3">About</h2>
<p class="text-gray-600">
<?php echo htmlspecialchars($user_data['about_me'] ?? 'No information provided yet.'); ?>
</p>
</div>
</div>
</div>
<!-- Reviews Section - Only show for freelancers -->
<?php if($_SESSION['user_type'] === 'freelancer'): ?>
<div class="glass-effect rounded-lg p-8">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-semibold text-gray-800">Reviews</h2>
<?php if(isset($_SESSION['user_type']) && $_SESSION['user_type'] === 'client'): ?>
<button onclick="openReviewForm('John Doe', 'Front-end Developer', 'E-commerce Website Redesign')"
class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition duration-300">
Write a Review
</button>
<?php endif; ?>
</div>
<!-- Existing Reviews -->
<div class="space-y-6">
<?php
// Fetch reviews for this freelancer
$reviews_sql = "SELECT r.*, u.name as client_name, p.title as project_title
FROM reviews r
JOIN users u ON r.client_id = u.user_id
JOIN projects p ON r.project_id = p.id
WHERE r.freelancer_id = ?
ORDER BY r.created_at DESC";
$reviews_stmt = $conn->prepare($reviews_sql);
$reviews_stmt->bind_param("i", $user_id);
$reviews_stmt->execute();
$reviews_result = $reviews_stmt->get_result();
if ($reviews_result->num_rows > 0) {
while ($review = $reviews_result->fetch_assoc()) {
// Calculate average rating
$avg_rating = ($review['quality_rating'] + $review['communication_rating']) / 2;
?>
<div class="border-b border-gray-200 pb-6">
<div class="flex items-center mb-2">
<div class="text-yellow-400 flex">
<?php for ($i = 1; $i <= 5; $i++): ?>
<i class="fas fa-star<?php echo ($i <= $avg_rating) ? '' : '-o'; ?>"></i>
<?php endfor; ?>
</div>
<span class="ml-2 text-gray-600"><?php echo number_format($avg_rating, 1); ?></span>
</div>
<p class="text-gray-600 mb-2">
"<?php echo htmlspecialchars($review['feedback']); ?>"
</p>
<p class="text-sm text-gray-500">
- <?php echo htmlspecialchars($review['client_name']); ?>,
Project: <?php echo htmlspecialchars($review['project_title']); ?>
</p>
<div class="mt-2 text-sm">
<span class="text-gray-500">Quality: <?php echo $review['quality_rating']; ?>/5</span>
<span class="text-gray-500 ml-4">Communication: <?php echo $review['communication_rating']; ?>/5</span>
<span class="text-gray-500 ml-4">Would rehire: <?php echo $review['would_rehire'] ? 'Yes' : 'No'; ?></span>
</div>
</div>
<?php
}
} else {
echo '<p class="text-gray-600">No reviews yet.</p>';
}
?>
</div>
</div>
<?php endif; ?>
</div>
<!-- Include the Review Form from review.html -->
<section id="review-form" class="py-12 hidden">
<!-- Your existing review form code here -->
</section>
</body>
</html>