-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogueo.php
92 lines (86 loc) · 2.7 KB
/
logueo.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
<!-- index.php -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login System</title>
<link rel="stylesheet" href="src/output.css">
<link rel="icon" href="img/logoemp.webp" type="image/webp">
</head>
<body>
<header class="container-fluid py-3 text-center">
<div class="row">
<div class="col-12">
<a href="/industrias/index.html"><img class="logo" src="img/logoemp.webp" alt="Logo" width="100" height="100"></img></a>
<h1 class="text-7xl font-serif ">Fracaso</h1>
<h3 class="frase font-sans">Somos tan transparentes como nuestras hojas</h3>
</div>
</div>
</header>
<div class="container rounded-lg space-y-6">
<h2 class="text-center">Inicia Sesión</h2>
<form id="loginForm">
<div class="form-group">
<label for="username">Nombre de usuario</label>
<input type="text" class="
form-control
border-2
border-gray-100
rounded-md
hover:border-b-green-300
duration-200
transition-colors"
id="username" name="username" placeholder="Pepitogamer" required>
</div>
<div class="form-group">
<label for="password">Contraseña</label>
<input type="password" class="
form-control
border-2
border-gray-100
rounded-md
hover:border-b-green-300
duration-200
transition-colors"
id="password" name="password" placeholder="contraseñaseg...">
</div>
<button type="submit" class="
border-2
rounded-full
px-5
py-3
hover:border-green-300
duration-200
transition-colors
">Login</button>
</form>
</div>
<script>
document.getElementById('loginForm').addEventListener('submit', async function(e) {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
try {
const response = await fetch('/industrias/lumen/public/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password }),
});
const data = await response.json();
if (response.ok) {
// Redirect to /plantilla/index.html on successful login
window.location.href = 'plantilla/index.html';
} else {
alert(data.message || 'Login failed');
}
} catch (error) {
console.error('Error:', error);
alert('An error occurred');
}
});
</script>
</body>
</html>