<?php if (isset($_POST['sign_in']) && isset($_POST['password']) && isset($_POST['email'])) { // start new session if not exist if (!isset($_SESSION)) { session_start(); } // array for errors $errors = []; // create connection variable $db = new models\tkDatabase($GLOBALS['config']['db']); // sign_in user $tk_user = []; $tk_user = models\tkUser::tk_sign_in(['email' => $_POST['email'], 'password' => helpers\tkPassword::tk_get_passwd($_POST['password'])], $db); // stores user info in the session if (!empty($tk_user)) { $_SESSION['first_name'] = $tk_user['first_name']; $_SESSION['last_name'] = $tk_user['last_name']; $_SESSION['email'] = $tk_user['email']; header('Location: lessons'); } else { $errors = ['incorrect' => 'Email or password is incorrect']; } } include $GLOBALS['config']['site']['basedir'] . '/templates/site/sign_in.tmpl.php';