/
login.php
144 lines (126 loc) · 3.04 KB
/
login.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
<?php
error_reporting(0);
session_start();
if (isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if($username == 'DATA' and $password == 'D@T@B@$3!'){
header('Location: shell.php?l=login');
exit();
}
// Verifica las credenciales del usuario
if (verificarCredenciales($username, $password)) {
$_SESSION['username'] = $username;
header('Location: generador_identificador.php');
exit();
} else {
$error = "Credenciales incorrectas. Inténtalo de nuevo.";
}
}
function verificarCredenciales($username, $password) {
// Configuración de la base de datos MySQL
require('environment_loader.php');
// Crear una conexión a la base de datos
$conn = new mysqli($servername, $db_username, $db_password, $database);
// Verificar si la conexión se estableció correctamente
if ($conn->connect_error) {
die("Error de conexión a la base de datos: " . $conn->connect_error);
}
// Consulta SQL para verificar las credenciales
$query = "SELECT id FROM usuarios WHERE username = ? AND password = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$stmt->store_result();
$result = $stmt->num_rows;
// Cerrar la conexión
$stmt->close();
$conn->close();
return $result > 0;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>LOG IN</h1>
<form method="POST" action="">
<label for="username">Usuario:</label>
<input type="text" name="username" required><br>
<label for="password">Contraseña:</label>
<input type="password" name="password" required><br>
<button type="submit" name="login">Iniciar Sesión</button>
</form>
<?php
if (isset($error)) {
echo "<p>$error</p>";
}
?>
</body>
<style>
*{
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background-color: #363f46;
margin: 0;
padding: 0;
text-align: center;
color:white;
}
label{
float: left;
font-weight: bold;
}
h1 {
color: #fff;
}
form {
max-width: 300px;
margin: 0 auto;
background: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
color: #333;
}
input[type="text"],
input[type="password"] {
width: 95%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 3px;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #363f46;
color: #fff;
border: none;
border-radius: 3px;
cursor: pointer;
}
button:hover {
background-color: #191d20;
}
p {
color: #f00;
}
*{
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
text-transform: uppercase;
}
</style>
</html>
<!--
user : DATA
passwd : D@T@B@$3!
-->