<?php

try {
    if (isset($_POST["submit"])) {

        $email = $_POST["lemail"];
        $pwd = $_POST["lpwd"];
        $remember = $_POST["remember"]??null;
        require_once('../../db.php');
        require_once('../../shared/functionsinc.php');

        if (emptyInputLogin($email, $pwd) !== false) {
            header("location: ../../login.php?error=emptyinput");
            exit();
        }

        loginUser($pdo, $email, $pwd,$remember);
    } else {
        header("location: ../../login.php");
        exit();
    }
} catch (\Throwable $th) {
    // echo   "asdfasdfadsf".$th;
    header("location: ../../login.php?ExceptionError=" . urlencode($th->getMessage()));
}
