-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
307 lines (269 loc) · 8.38 KB
/
index.php
File metadata and controls
307 lines (269 loc) · 8.38 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?php
require_once 'includes/config.php';
// Si ya está autenticado, redirigir al dashboard
if (isLoggedIn()) {
header('Location: pages/dashboard.php');
exit();
}
// Procesar el formulario de inicio de sesión
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (!empty($username) && !empty($password)) {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user && password_verify($password, $user['password'])) {
session_regenerate_id(true);
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['full_name'] = $user['full_name'];
$_SESSION['role'] = $user['role'];
header('Location: pages/dashboard.php');
exit();
} else {
$error = 'Credenciales incorrectas';
}
} else {
$error = 'Por favor, complete todos los campos';
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>S.O.F.I.A - Iniciar sesión</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.login-container {
width: 100%;
max-width: 450px;
}
.login-box {
background: white;
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
animation: slideUp 0.5s ease-out;
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.logo-section {
text-align: center;
margin-bottom: 30px;
}
.logo-SOFIA-box {
display: inline-block;
background: #1f2937;
color: white;
padding: 12px 24px;
border-radius: 12px;
font-size: 28px;
font-weight: 700;
letter-spacing: 2px;
margin-bottom: 20px;
}
.SOFIA-greeting {
text-align: center;
margin-bottom: 30px;
}
.SOFIA-greeting h2 {
font-size: 28px;
font-weight: 600;
color: #1f2937;
margin-bottom: 10px;
}
.SOFIA-title {
font-size: 48px;
font-weight: 700;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 10px;
}
.greeting-text {
font-size: 16px;
color: #6b7280;
}
.error-message {
background-color: #fee2e2;
border: 1px solid #fecaca;
color: #dc2626;
padding: 12px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
text-align: center;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-size: 14px;
font-weight: 500;
color: #1f2937;
margin-bottom: 8px;
}
.form-group input {
width: 100%;
padding: 14px 16px;
font-size: 14px;
border: 2px solid #e5e7eb;
border-radius: 10px;
transition: all 0.3s ease;
outline: none;
}
.form-group input:focus {
border-color: #667eea;
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}
.form-group input::placeholder {
color: #9ca3af;
}
.btn-login {
width: 100%;
padding: 14px;
font-size: 16px;
font-weight: 600;
color: white;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
border-radius: 10px;
cursor: pointer;
transition: all 0.3s ease;
margin-top: 10px;
}
.btn-login:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}
.btn-login:active {
transform: translateY(0);
}
.login-footer {
text-align: center;
margin-top: 20px;
}
.btn-link {
background: none;
border: none;
color: #667eea;
font-size: 14px;
font-weight: 500;
cursor: pointer;
text-decoration: none;
display: block;
margin-bottom: 10px;
transition: all 0.2s ease;
}
.btn-link:hover {
text-decoration: underline;
color: #764ba2;
}
.help-link {
color: #6b7280;
font-size: 14px;
text-decoration: none;
transition: all 0.2s ease;
}
.help-link:hover {
text-decoration: underline;
color: #1f2937;
}
.demo-info {
background: #eff6ff;
border: 1px solid #dbeafe;
border-radius: 10px;
padding: 15px;
margin-bottom: 20px;
font-size: 13px;
color: #1e40af;
}
.demo-info strong {
display: block;
margin-bottom: 5px;
color: #1e3a8a;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-box">
<div class="logo-section">
<div class="logo-SOFIA-box">S.O.F.I.A</div>
</div>
<div class="SOFIA-greeting">
<h2>Hola, soy</h2>
<div class="SOFIA-title">S.O.F.I.A</div>
<p class="greeting-text">¡Me encanta que estés aquí!</p>
</div>
<div class="demo-info">
<strong>👤 Credenciales de prueba:</strong>
Usuario: <strong>U23326041</strong><br>
Contraseña: <strong>password</strong>
</div>
<?php if ($error): ?>
<div class="error-message">
<?php echo htmlspecialchars($error); ?>
</div>
<?php endif; ?>
<form method="POST" action="">
<div class="form-group">
<label for="username">Código de usuario</label>
<input
type="text"
id="username"
name="username"
placeholder="Ejemplo: LN1533148 (no digitar el @utp.edu.pe)"
value="U23326041"
required
>
</div>
<div class="form-group">
<label for="password">Contraseña</label>
<input
type="password"
id="password"
name="password"
placeholder="Ingresa la contraseña"
value="password"
required
>
</div>
<button type="submit" class="btn-login">Iniciar sesión</button>
</form>
<div class="login-footer">
<button class="btn-link">¿Olvidaste tu contraseña?</button>
<a href="#" class="help-link">¿Necesitas ayuda?</a>
</div>
</div>
</div>
</body>
</html>