예제 #1
0
 function run()
 {
     $sth = $this->db->prepare("SELECT userid, role FROM user WHERE \n\t\t\tusername = :username AND password = :password");
     $sth->execute(array(':username' => $_POST['username'], ':password' => \Libs\Hash::create('sha256', $_POST['password'], HASH_PASSWORD_KEY)));
     $data = $sth->fetch();
     $count = $sth->rowCount();
     if ($count > 0) {
         // login
         \Libs\Session::init();
         \Libs\Session::set('role', $data['role']);
         \Libs\Session::set('loggedIn', true);
         \Libs\Session::set('userid', $data['userid']);
         header('location: ../dashboard');
     } else {
         header('location: ../login');
     }
 }
예제 #2
0
 public function editSave($data)
 {
     $postData = array('username' => $data['username'], 'password' => \Libs\Hash::create('sha256', $data['password'], HASH_PASSWORD_KEY), 'role' => $data['role']);
     $this->db->update('user', $postData, "`userid` = {$data['userid']}");
 }