Files
ayr2026/admin/login.php
T
2026-09-20 13:28:57 -03:00

130 lines
3.6 KiB
PHP

<?php
require_once '../config/db.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = trim($_POST['email']);
$password = $_POST['password'];
$stmt = $pdo->prepare("SELECT id, nombre, password FROM admin_users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
// Comparación directa sin hash (como pediste)
if ($user && $password === $user['password']) {
$_SESSION['admin_id'] = $user['id'];
$_SESSION['admin_nombre'] = $user['nombre'];
header('Location: dashboard.php');
exit;
} else {
$error = 'Email o contraseña incorrectos';
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login - Amor y Roma</title>
<style>
body {
font-family: 'Raleway', sans-serif;
background: #eaf0ee;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
}
.login-container {
background: white;
padding: 3rem;
border-radius: 16px;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
}
h1 {
color: #221728;
margin-bottom: 0.5rem;
font-family: 'Literata', serif;
font-style: italic;
}
.subtitle {
color: #666;
margin-bottom: 2rem;
font-size: 0.9rem;
}
.form-group {
margin-bottom: 1.5rem;
}
label {
display: block;
margin-bottom: 0.5rem;
color: #003f52;
font-weight: 600;
font-size: 0.9rem;
}
input[type="email"],
input[type="password"] {
width: 100%;
padding: 0.75rem;
border: 1.5px solid rgba(0, 63, 82, 0.2);
border-radius: 8px;
font-size: 1rem;
box-sizing: border-box;
}
input:focus {
outline: none;
border-color: #ba124d;
}
.btn-login {
width: 100%;
padding: 0.85rem;
background: #ba124d;
color: white;
border: none;
border-radius: 24px;
font-weight: 600;
cursor: pointer;
font-size: 1rem;
transition: background 0.3s;
}
.btn-login:hover {
background: #9c0f40;
}
.error {
background: #fee;
color: #c00;
padding: 0.75rem;
border-radius: 8px;
margin-bottom: 1rem;
font-size: 0.9rem;
}
</style>
</head>
<body>
<div class="login-container">
<h1>Amor y Roma</h1>
<p class="subtitle">Panel de Administración del Blog</p>
<?php if ($error): ?>
<div class="error"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" required autofocus>
</div>
<div class="form-group">
<label for="password">Contraseña</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="btn-login">Ingresar</button>
</form>
</div>
</body>
</html>