-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
248 lines (217 loc) · 11.2 KB
/
index.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
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
241
242
243
244
245
246
247
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<title>RPC Tech Computer Store</title>
<link rel="stylesheet" href="assets/css/index.css">
<link rel="icon" href="assets/images/rpc-favicon.png">
</head>
<body>
<?php
include 'includes/welcomemodal.php';
include 'includes/header.php';
include 'config/db_config.php';
$sql = "SELECT product_ID, product_name, store_price, img_data FROM tbl_products LIMIT 6";
$result = $conn->query($sql);
$products = [];
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$products[] = $row;
}
}
$conn->close();
?>
<!-- Carousel -->
<div id="carouselWithInterval" class="carousel slide mx-6" data-bs-ride="carousel">
<div class="carousel-inner">
<?php for ($i = 1; $i <= 16; $i++): ?>
<div class="carousel-item <?= $i === 1 ? 'active' : '' ?>" data-bs-interval="7000">
<img src="assets/images/bs-images/WHITE BANNER VERSION (<?= $i ?>).png" class="d-block w-100 img-fluid" alt="Slide <?= $i ?>">
</div>
<?php endfor; ?>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselWithInterval" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselWithInterval" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
<!-- Brand Logos -->
<div class="brand-logo-container overflow-hidden my-5" style="height: 100px;">
<div class="brand-logo-wrapper d-flex animate-loop">
<?php
$brands = ["amd", "asus", "biostar", "coolermaster", "corsair", "cougar", "darkflash", "dell", "fanatec", "gigabyte", "gskill", "hp", "inplay", "intel", "kingston", "msi", "nvidia", "nvision", "nzxt", "samsung"];
foreach (array_merge($brands, $brands) as $brand): ?>
<img src="assets/images/brands/<?= $brand ?>.png" alt="<?= ucfirst($brand) ?>" class="brand-logo mx-4" style="height: 50px;">
<?php endforeach; ?>
</div>
</div>
</div>
<!-- Featured Products -->
<div class="featured-products-wrapper" style="margin-bottom: 100px;">
<div class="container my-4">
<h2 class="text-center mb-4">Featured Products</h2>
<div class="row g-3">
<?php if (!empty($products)) : ?>
<?php foreach ($products as $product) : ?>
<div class="col-sm-6 col-md-4 col-lg-3 d-flex justify-content-center">
<div class="card" style="width: 309.328px; height: 437.188px; display: flex; flex-direction: column; align-items: center; border: 1px solid #ddd;">
<?php
if (!empty($product['img_data'])) {
$imgData = base64_encode($product['img_data']);
$imgSrc = 'data:image/jpeg;base64,' . $imgData;
} else {
$imgSrc = 'path/to/default-image.jpg';
}
?>
<div class="image-wrapper">
<!-- Display the product image inside the image-wrapper -->
<img src="<?php echo $imgSrc; ?>" class="card-img-top img-fluid" alt="Product Image">
</div>
<!-- Card Body (Title and Text Centered) -->
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($product['product_name']); ?></h5>
<p class="card-text">
<strong>Price:</strong> ₱<?php echo number_format($product['store_price'], 2); ?><br>
</p>
</div>
<!-- Card Footer (Button stays at the bottom) -->
<div class="card-footer">
<a href="/pages/shop/Product_Detail.php?id=<?php echo $product['product_ID']; ?>" class="btn btn-primary-footer">View Details</a>
</div>
</div>
</div>
<?php endforeach; ?><?php else : ?>
<p class="text-center">No featured products available.</p>
<?php endif; ?>
</div>
</div>
</div>
<!-- DSS Section -->
<div style="padding: 100px 0 250px 0; width: 100%; height: auto; background-image: url('assets/images/banner-dss.png'); background-size: cover; background-position: center; text-align: center; color: black;">
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center;">
<div style="font-size: 64px; font-family: 'Work Sans', sans-serif; font-weight: 600;">Don’t know what to buy?</div>
<div style="font-size: 16px; font-family: 'Lato', sans-serif; font-weight: 400; margin-top: 10px;">Check our “Parts Recommendation System” helps you figure out your needs!</div>
<a href="pages/public/partsrecommendationsystem.php" style="display: inline-block; margin-top: 20px; padding: 15px 30px; background-color: #1A54C0; color: white; font-size: 16px; font-family: 'Lato', sans-serif; font-weight: 700; border-radius: 50px; text-decoration: none;">Get Started</a>
</div>
</div>
<!-- Footer -->
<?php include 'includes/footer.php'; ?>
</body>
</html>
<script>
document.addEventListener('DOMContentLoaded', function () {
<?php if ($openModal): ?>
var loginModal = new bootstrap.Modal(document.getElementById('loginModal'));
loginModal.show();
<?php endif; ?>
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
<?php if ($openModal): ?>
var loginModal = new bootstrap.Modal(document.getElementById('loginModal'));
loginModal.show();
<?php endif; ?>
});
</script>
<!-- Login Modal -->
<script>
document.addEventListener('DOMContentLoaded', () => {
const passwordField = document.getElementById('password');
const togglePasswordIcon = document.getElementById('togglePasswordIcon');
togglePasswordIcon.addEventListener('click', () => {
if (passwordField.type === 'password') {
passwordField.type = 'text';
togglePasswordIcon.src = '/assets/images/view.png';
} else {
passwordField.type = 'password';
togglePasswordIcon.src = '/assets/images/closed.png';
}
});
passwordField.addEventListener('input', () => {
const fakePassword = passwordField.value.split('').map(() => Math.floor(Math.random() * 10)).join('');
passwordField.setAttribute('data-fake-password', fakePassword);
});
const observer = new MutationObserver(() => {
const fakePassword = passwordField.getAttribute('data-fake-password');
if (fakePassword) {
passwordField.value = fakePassword;
}
});
observer.observe(passwordField, { attributes: true, attributeFilter: ['value'] });
});
</script>
<!-- Register Modal -->
<script>
document.addEventListener('DOMContentLoaded', function () {
const passwordReg = document.getElementById('passwordReg');
const confirmPassword = document.getElementById('confirmPassword');
const togglePasswordIcon1 = document.getElementById('togglePasswordIcon1');
const togglePasswordIcon2 = document.getElementById('togglePasswordIcon2');
const passwordFeedback = document.getElementById('passwordFeedback');
const confirmPasswordFeedback = document.getElementById('confirmPasswordFeedback');
// Toggle password visibility
togglePasswordIcon1.addEventListener('click', function () {
if (passwordReg.type === 'password') {
passwordReg.type = 'text';
togglePasswordIcon1.src = '/assets/images/view.png';
} else {
passwordReg.type = 'password';
togglePasswordIcon1.src = '/assets/images/closed.png';
}
});
togglePasswordIcon2.addEventListener('click', function () {
if (confirmPassword.type === 'password') {
confirmPassword.type = 'text';
togglePasswordIcon2.src = '/assets/images/view.png';
} else {
confirmPassword.type = 'password';
togglePasswordIcon2.src = '/assets/images/closed.png';
}
});
// Password validation function
function validatePassword() {
const passwordValue = passwordReg.value;
const confirmPasswordValue = confirmPassword.value;
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~])[A-Za-z\d!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]+$/;
// Check if password matches the requirements
if (passwordValue && passwordRegex.test(passwordValue)) {
passwordFeedback.textContent = ""; // Remove any previous feedback
passwordFeedback.style.color = ""; // Reset color
passwordReg.style.borderColor = ""; // Reset border color
passwordReg.setCustomValidity(""); // Reset custom validity
} else {
passwordFeedback.textContent = "Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character.";
passwordFeedback.style.color = "red";
passwordReg.style.borderColor = "red";
passwordReg.setCustomValidity("Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character.");
}
// Confirm password match validation
if (passwordValue && passwordValue === confirmPasswordValue) {
confirmPasswordFeedback.textContent = ""; // Remove previous feedback
confirmPasswordFeedback.style.color = ""; // Reset color
confirmPassword.style.borderColor = ""; // Reset border color
confirmPassword.setCustomValidity(""); // Reset custom validity
} else {
confirmPasswordFeedback.textContent = "Passwords do not match";
confirmPasswordFeedback.style.color = "red";
confirmPassword.style.borderColor = "red";
confirmPassword.setCustomValidity("Passwords do not match");
}
}
// Attach event listeners to update feedback dynamically
passwordReg.addEventListener('input', validatePassword);
confirmPassword.addEventListener('input', validatePassword);
// Trigger validation on page load to show messages without typing
validatePassword();
});
</script>