<?php
session_start();
require_once __DIR__ . '/../config.php';

// DELETE OLD admins table and make new one with PLAIN password
$pdo->query("DROP TABLE IF EXISTS admins");
$pdo->query("CREATE TABLE admins (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) UNIQUE NOT NULL,
    password VARCHAR(255) NOT NULL
)");
$pdo->query("INSERT INTO admins (username, password) VALUES ('admin', 'reckon123')");

// NOW LOGIN — NO HASHING
if ($_POST['u'] === 'admin' && $_POST['p'] === 'reckon123') {
    $_SESSION['admin_id'] = 1;
    $_SESSION['admin_name'] = 'admin';
    header("Location: index.php");
    exit;
}

header("Location: login.php?e=1");
exit;
?>