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'); } }
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']}"); }