<?php

session_start();
require_once "php/functions.php";
$user = new User();
$user->checkCookies();
$user->checkSession();
if (isset($_POST["submit"])) {
    $codPassword = sha1(md5($_POST["pass"]));
    $login = $user->check_login($_POST['user'], $codPassword);
    if ($login) {
        if (isset($_POST['remember'])) {
            $user->setCookies($_POST['user']);
        }
        header("location: /iot/#/home");
    } else {
        $error = "Sorry username or password is wrong!";
    }
}
?>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>IoT | Login</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">