Untitled

Anonymous
plain_text
02/23/2026 3:47 AM
968 B
10
Indexable
<?php
require_once __DIR__ . '/../helpers/functions.php';
require_once __DIR__ . '/../helpers/auth.php';

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header("Location: ../pages/login.php?msg=Invalid%20Request");
    exit;
}

$username = strtolower(cleanInput($_POST['username'] ?? ''));
$password = $_POST['password'] ?? '';

if ($username === '' || $password === '') {
    header("Location: ../pages/login.php?msg=Please%20enter%20username%20and%20password");
    exit;
}

$user = auth_attempt($username,$password);
if (!$user) {
    header("Location: ../pages/login.php?msg=Invalid%20credentials");
    exit;
}

auth_login($user);
header("Location: ../pages/list_students.php");
exit;

?>
Editor is loading...
Leave a Comment