<?php

if (core::ifPost("from") AND core::getPost("from") == "login") {
    $connect = user::connect(core::getPost());

    if($connect == TRUE){
        historique::recRef("/login.html");
        historique::add(array(
            "idType" => historique::getIdRef("CONNEXION"),
            "idUser" => session::getId(),
            "idPage" => historique::getIdRef("/login.html"),
            "log" => $_SERVER['REMOTE_ADDR']
        ));
    }
    
    header("Location: /");
    exit();
} else {
    header('HTTP/1.0 401 Unauthorized');
    exit();
}