<?php
//controllers/login.php
function login($kw){
require_once __DIR__.'/../setting.php';
require_once __DIR__.'/admin/users/table.php';
table($kw);
$kw->mset([
'appName'=>$setting['siteTitle'],
'title'=>'ទំព័រចុះឈ្មោះ',
'date'=>$setting['date'],
'message'=>$setting['message']
]);
$view=new View;
echo $view->render('views/login.php');
}
<?php
//controllers/login_post.php
function checkUser($kw){
require_once 'setting.php';
$kw->mset([
'appName'=>$setting['siteTitle'],
'title'=>'ទំព័រគ្រប់គ្រង',
'date'=>$setting['date'],
'message'=>$setting['message']
]);
if($_SESSION){
$view=new View;
echo $view->render('views/admin/index.php');
}else{
$sql = 'SELECT * FROM users WHERE email="'.$kw->get('POST.email').'"';
$email = $kw->get('DB')->exec($sql);
if($email){
$sql = 'SELECT * FROM users WHERE password="'.$kw->get('POST.password').'"';
$password = $kw->get('DB')->exec($sql);
if($password){
$_SESSION["password"] = $user[0]['password'];
$_SESSION["email"] = $user[0]['email'];
$view=new View;
echo $view->render('views/admin/index.php');
}else{
$kw->set('message', 'ពាក្យសំងាត់មិនត្រឹមត្រូវទេ');
$view=new View;
echo $view->render('views/login.php');
}
}else{
$kw->set('message', 'Email មិនត្រឹមត្រូវទេ');
$view=new View;
echo $view->render('views/login.php');
}
}
}
Epizy: http://khmerweb.epizy.com