Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App;
- class Admin
- {
- public $msg;
- private $db;
- private $helper;
- private $table;
- public function __construct()
- {
- $this->db = new Database();
- $this->helper = new Helper();
- $this->table = 'admins';
- }
- public function adminLogin($data)
- {
- $adminData = array(
- 'username' => $this->helper->validation($data['username']),
- 'password' => $this->helper->validation($data['password']),
- );
- if (in_array(NULL, $adminData))
- {
- $msg = 'Prašome užpildyti visus laukelius';
- Session::set('msg', $msg);
- }
- else
- {
- $condition = array(
- 'select' => 'id, username, password',
- 'where' => 'username = "' . $adminData['username'] . '" AND password = "' . $adminData['password'] . '"',
- 'return_type' => 'single',
- );
- $admin = $this->db->select($this->table, $condition);
- if ($admin)
- {
- Session::set('adminLogin', true);
- Session::set('adminId', $admin['id']);
- }
- else
- {
- $msg = 'Nepavyko prisijungti. Prašome bandyti vėl.';
- Session::set('msg', $msg);
- }
- }
- header('Refresh: 0');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement