Lania/registro.php

190 lines
7.0 KiB
PHP

<?php
require_once 'model/register.php';
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (isset($_SESSION['admin_logged']) && $_SESSION['admin_logged'] === true) {
header('Location: dashboard.php');
exit;
}
// Procesar registro
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$nombre = $_POST['nombre'];
$password = $_POST['password'];
$res = createAdmin($nombre, $password);
if ($res === true) {
$success = 'Administrador registrado correctamente.';
} else {
$error = 'Error al registrar: ' . $res;
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Registro Admin</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background: linear-gradient(to right, #eef7ff, #7597b4); /* Gradiente azul para LANIA */
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px; /* Padding general para pantallas pequeñas */
box-sizing: border-box;
}
.login-wrapper {
display: flex;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
overflow: hidden; /* Para que las esquinas redondeadas funcionen bien con el contenido */
max-width: 900px; /* Ancho máximo para el contenedor de login */
width: 100%;
}
.login-image-section {
flex: 1;
background: url('assets/inicio.png') no-repeat center center; /* Asegúrate de que esta ruta sea correcta */
background-size: cover;
min-height: 350px; /* Altura mínima para la imagen en móvil */
display: none; /* Ocultar por defecto en móviles */
}
@media (min-width: 768px) { /* Mostrar la imagen en pantallas medianas y grandes */
.login-image-section {
display: block;
}
}
.login-form-section {
flex: 1;
padding: 40px;
display: flex;
flex-direction: column;
justify-content: center;
}
.login-form-section h2 {
margin-bottom: 25px;
color: #484848; /* Color del texto del título */
text-align: center;
font-weight: 700;
}
.login-form-section .form-label {
font-weight: 500;
color: #343a40;
}
.login-form-section .form-control {
border-radius: 5px;
border: 1px solid #ced4da;
padding: 10px 15px;
transition: all 0.3s ease;
}
.login-form-section .form-control:focus {
border-color: #133dd5;
box-shadow: 0 0 0 0.25rem rgba(19, 61, 213, 0.25);
}
.btn-primary, .btn-secondary { /* Apply general button styles */
background-color: #5691cc; /* LANIA blue */
border-color:rgb(122, 133, 173);
padding: 10px 20px;
font-size: 1.1em;
font-weight: 600;
border-radius: 5px;
transition: all 0.3s ease;
color: white; /* Text color for primary button */
}
.btn-primary:hover {
background-color: #3e4c82; /* Darker shade on hover */
border-color: #0a248a;
transform: translateY(-2px); /* Pequeño efecto al pasar el mouse */
}
.btn-secondary {
background-color: #6c757d; /* Bootstrap secondary color */
border-color: #6c757d;
}
.btn-secondary:hover {
background-color: #5a6268;
border-color: #545b62;
transform: translateY(-2px);
}
.alert {
margin-top: 20px;
text-align: center;
border-radius: 5px;
font-weight: 400;
}
.text-center.mt-4 p {
color: #6c757d;
font-size: 0.9em;
}
.social-login-buttons .btn {
border-radius: 50px; /* Botones más redondeados para redes sociales */
padding: 8px 20px;
font-size: 0.9em;
margin: 0 5px;
transition: all 0.3s ease;
}
.social-login-buttons .btn:hover {
transform: translateY(-2px);
}
/* Estilos para el logo o icono */
.login-logo {
text-align: center;
margin-bottom: 30px;
}
.login-logo img {
max-width: 120px; /* Ajusta el tamaño del logo */
height: auto;
}
</style>
</head>
<body>
<div class="login-wrapper">
<div class="login-image-section">
</div>
<div class="login-form-section">
<div class="login-logo">
<img src="assets/logo.png" alt="Logo LANIA" class="img-fluid">
</div>
<h2>Registrar Administrador</h2>
<?php if (isset($success)): ?>
<div class="alert alert-success" role="alert"><?= $success ?></div>
<?php elseif (isset($error)): ?>
<div class="alert alert-danger" role="alert"><?= $error ?></div>
<?php endif; ?>
<form method="post">
<div class="mb-3">
<label for="nombre" class="form-label">Nombre:</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-user"></i></span>
<input type="text" id="nombre" name="nombre" class="form-control" required>
</div>
</div>
<div class="mb-4">
<label for="password" class="form-label">Contraseña:</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-lock"></i></span>
<input type="password" id="password" name="password" class="form-control" required>
</div>
</div>
<div class="d-flex justify-content-between mt-4">
<button type="submit" class="btn btn-primary">Registrar</button>
<a href="sesion.php" class="btn btn-secondary">Ir al Login</a>
</div>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>