Exemplo n.º 1
0
 public static function login($username, $password)
 {
     $user_table = new UserTable();
     $result = $user_table->select($username, $password);
     if ($result != false) {
         // 设置Session
         SessionUtil::set(array('is_login' => true, 'user_id' => $result['user_id'], 'user_login' => $result['user_login'], 'user_name' => $result['user_name'], 'user_phone' => $result['user_phone'], 'user_email' => $result['user_email'], 'user_type' => $result['user_type'], 'user_authority' => SQLUtil::get_authority($result['user_type'], $result['user_authority'])));
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public function signupHandler()
 {
     $username = Util::fetch_post('username');
     $password = Util::fetch_post('password');
     $realname = Util::fetch_post('realname');
     if ($username == null || $password == null || $realname == null) {
         $this->error(2);
     }
     $userTable = new UserTable();
     if ($userTable->is_exist($username)) {
         $this->errorMsg('该用户已存在');
     }
     // 插入数据
     $userTable->insert($username, $password, $realname);
     $result = $userTable->select($username, $password);
     $userExtraTable = new UserExtraTable();
     $userExtraTable->insert($result['user_id']);
     SQLUtil::login($username, $password);
     Util::go(URL . 'manager/');
 }