/** * main login method * @author thanhtuan * @param $username user name * @param $password pass word * @return true if login successful and otherwise * */ public function login($username, $password) { $dao = new AccountDAO(); $account = $dao->getInfo($username); // if account exists if ($account != null) { $psswd = $account["Password"]; // if login successful if ($psswd === $password) { session_start(); $_SESSION['is_login'] = true; $_SESSION['staff_type'] = $account["LoaiNV"]; $_SESSION['staff_id'] = $account["MaNV"]; $_SESSION['username'] = $account["TenNV"]; $_SESSION['restaurant'] = $account["MaNH"]; return true; } } // if login unsuccessful return false; }
public function execute() { $user = json_decode($_GET['user']); $dao = new AccountDAO(); $dao->create($user); }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); session_start(); require_once $_SERVER['DOCUMENT_ROOT'] . '/libs.inc.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/backend/DAO/AccountDAO.php'; $accountDAO = new AccountDAO(); header('Content-type: text/html; charset=utf-8'); if ($_SESSION['role'] != 'admin') { $accountDAO = new AccountDAO(); if (isset($_POST['username']) || isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; $accountDAO->getUserWithUsernamePassword($username, $password); } $smarty->display("login/admin_index.tpl"); } else { require_once $_SERVER['DOCUMENT_ROOT'] . '/Admin/view/menu/index.php'; $smarty->display("menu/menu.tpl"); }