Primer Commit
This commit is contained in:
118
index.php
Normal file
118
index.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
// Iniciar o reanudar la sesión solo si no está iniciada
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Verificar si ya hay una sesión activa
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
// Si ya hay una sesión activa, redirige a la página deseada
|
||||
header('Location: portal.php');
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Administracion TheThinkerLab</title>
|
||||
|
||||
<link rel="shortcut icon" href="assets/img/favicon.png">
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body
|
||||
style="background-image: url(assets/img/descarga.jpg); background-size: 100%; background-position: bottom; background-repeat:repeat-y;">
|
||||
|
||||
<center><br><br><br><br><br>
|
||||
|
||||
<div class="container"
|
||||
style="background-color: rgb(255, 255, 255); padding: 2%; width: 25rem; box-shadow: 0px 0px 36px 0px rgba(0, 0, 0, 0.219);">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<img src="assets/img/hum.png" width="130rem" alt="">
|
||||
|
||||
<p class="textonormbold">Portal de Administración Pasarela</p>
|
||||
<p class="textomin">Iniciar sesión</p>
|
||||
<?php if (isset($error)) {
|
||||
echo "<p>$error</p>";
|
||||
} ?>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="email"><i class="fa-solid fa-envelope"></i></span>
|
||||
<input type="text" id="username" name="username" required required class="form-control"
|
||||
placeholder="Correo electrónico" aria-label="Correo electrónico" aria-describedby="email">
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="Password"><i class="fas fa-lock"></i>
|
||||
</span>
|
||||
<input type="password" id="password" name="password" required required class="form-control"
|
||||
placeholder="Password" aria-label="Password" aria-describedby="Password">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="col-lg-6">
|
||||
<img src="assets/img/factura.jpg" width="80%" alt="">
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<a href="#"><button onclick="enviarFormulario()" name="submit"
|
||||
style="background-color: #00c0ff; color: white; border: none; padding: 2%;">Iniciar
|
||||
sesión</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</center>
|
||||
|
||||
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://kit.fontawesome.com/b3551d620b.js" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
<script>
|
||||
function enviarFormulario() {
|
||||
//console.log("envio");
|
||||
var username = $('#username').val();
|
||||
var password = $('#password').val();
|
||||
//console.log(password)
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: './ManipulacionUser.php',
|
||||
data: {
|
||||
operacion: "Inicio",
|
||||
Correo: username,
|
||||
Contrasena: password
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response)
|
||||
if (response == 1) {
|
||||
setTimeout(function() {
|
||||
window.location.href = 'portal.php';
|
||||
// Cierra la página actual
|
||||
window.close();
|
||||
}, 1000);
|
||||
} else if (response == 'admin') {
|
||||
window.location.href = 'portal.php';
|
||||
} else {
|
||||
console.log("RESPUESTA LOGIN: "+response);
|
||||
// Reemplazo de alerta estándar con SweetAlert
|
||||
Swal.fire('Error', 'Credenciales incorrectas', 'error');
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
console.error('Error en la solicitud:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user